-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Errors with malformed CSS #179
Comments
As for the cause of the error: I'm for having a whitelist of characters (i.e., a regular expression) which we can use to validate those selectors before using them. |
I had a little look into matching selectors - it's not simple at all! I think the only invalid char in that selector is |
So I propose discarding any selectors that contain a "<". What do you think about this? And would you be willing to create a PR for this? |
Yes, I think that's reasonable. Where would I find the code that identifies selectors? |
That should be https://github.com/jjriv/emogrifier/blob/master/Classes/Emogrifier.php#L337 in the method parseSelectors. |
As I've been reading, it's very hard to match CSS selectors with a regex as they are not a regular grammar. I'm thinking that it would be easier to apply a simple filter to remove stray tags before trying to parse the styles, for example:
or even a simple |
This was fixed by #400 (in 2.0.0), with some prior relevant changes in #361 and #392. The unit test So I'm closing this now. |
I ran into two errors when processing some malformed style tags.
The style tag contained some stray HTML injected by ckeditor:
Trying to process this produced two errors. The first is caused by it choosing
<style data-cke-temp="1">html
as a selector, which will not convert to a valid xpath query:The second is a consequence of this, attempting to iterate over the failed result of the query because the return value is not checked:
Obviously it would be better if bad CSS was not passed in in the first place, but it would be better to ignore it than throw errors.
The text was updated successfully, but these errors were encountered: