rgrove / crass

A Ruby CSS parser that's fully compliant with the CSS Syntax Level 3 specification.
MIT License
139 stars 14 forks source link

Parser on CSS attribute with nothing after it. #2

Closed abachman closed 10 years ago

abachman commented 10 years ago

Specifically, when trying to parse the string "font-family:".

I've forked and committed a breaking test and the code to fix it here: https://github.com/abachman/crass/commit/eab9b3dc7cb1244ae6a3dccd6bfc75b4d94b2da4

The problem came up in use of the sanitize gem, when trying to sanitize email message bodies and we came across this piece of work:

<p style="font-family:" SegoeUI?,Frutiger,?FrutigerLinotype?,?DejavuSans?,?HelveticaNeue?,Tahoma,sans-serif;font-size:7.5pt;?="">blah blah blah</p>

We want to let some styles through, so we're permitting style attributes, but we don't want to let all styles through so we're limiting the allowed properties. Until we did that, parsing worked fine. I'm not sure which email editor is responsible for that nonsense, but it's breaking our ability to process data in production, which stinks.

rgrove commented 10 years ago

@abachman: Thanks! I'll pull this in.

rgrove commented 10 years ago

Merged and pushed a new gem.