-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when encoded quotes are used in html attribute #482
Comments
I just experienced this bug. Is there any progress or anyone actively working on it? If not, I'd be happy to contribute a fix, however, I am new to contributing to Juice therefore I'd appreciate some guidance first. Thank you! |
I use v9.1.0, and it happens for me after dependencies update, too. Looks like the issue is in |
Here's a fix! #526 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have some HTML which is a result of other processing and already contains some inline styles. I'm then using juice to inline some global CSS, as the output must be used as an email content. I'm using Google Fonts loaded by my CMS, some of them are quoted - produced CSS looks like this:
font-family: "One Sans", sans-serif;
which is a valid CSS. When inlined into a div style attribute, it gets encoded:This causes error in Juice, as it does not decode the HTML entities and instead tries to parse it as css rules. Here are the objects from juice parsing:
And it fails with the error:
![2p84jCbJ3V](https://private-user-images.githubusercontent.com/25011639/350412741-f8a60637-1848-4085-bcb5-955117984c13.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2MTQ1OTMsIm5iZiI6MTczOTYxNDI5MywicGF0aCI6Ii8yNTAxMTYzOS8zNTA0MTI3NDEtZjhhNjA2MzctMTg0OC00MDg1LWJjYjUtOTU1MTE3OTg0YzEzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDEwMTEzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTgyOGY0MDJkODFmYTMwYTZlN2IzOTRjZjU3OTg2MzdhM2ZlODczYjQ0MDQ3YzdhNjVkODM3ZDg3ZmZhNDYyZWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.h8M0gZPlVqUXoRZdalV8bdEsU55r81ZrYSpjPcCpbw8)
Cannot read properties of undefined (reading 'indexOf')
.Minimal reproduction
Just create an
input.html
file and paste this code:Then run:
And see the error.
Solution
Juice should decode HTML entities after reading an attribute value and before parsing it to CSS rules. This way it could convert
"
(and other such strings) back to the proper double-quote character ("
) so that it woudn't contain any semi-colons and could be properly parsed into CSS.The text was updated successfully, but these errors were encountered: