premailer / css_parser

Ruby CSS Parser
Other
279 stars 110 forks source link

Handles font-size/ line-height shorthand with spaces #89

Closed alduethadyn closed 7 years ago

alduethadyn commented 7 years ago

Description

While attempting use Premailer to inline CSS for emails originating from Amazon, we started seeing errors when expanding font shorthands that have spaces after the forward slash - e.g font-size/ line-height:

NoMethodError: undefined method `strip' for nil:NilClass
/bundle/gems/css_parser-1.5.0/lib/css_parser/rule_set.rb:99:in `block in each_declaration'
/bundle/gems/css_parser-1.5.0/lib/css_parser/rule_set.rb:97:in `each'
/bundle/gems/css_parser-1.5.0/lib/css_parser/rule_set.rb:97:in `each_declaration'
/bundle/gems/css_parser-1.5.0/lib/css_parser.rb:81:in `block in merge'
/bundle/gems/css_parser-1.5.0/lib/css_parser.rb:69:in `each'
/bundle/gems/css_parser-1.5.0/lib/css_parser.rb:69:in `merge'
...

An example of the email body particulars:

...
a {
    text-decoration: none;
    color: #006699;
    font: 14px/ 16px Arial, sans-serif;
}
...
f_=3Dpe_2640190_232748420_TE_simp_" title=3D"Visit Amazon.com" style=3D"tex=
t-decoration: none; color: rgb(0, 102, 153); font: 14px/ 16px Arial, sans-s=
erif"><img id=3D"amazonLogo" alt=3D"Amazon" src=3D"http://g-ecx.images-amaz=
on.com/images/G/01/x-locale/cs/te/logo.png" style=3D"width: 107px; height: =
31px; border: 0" /></a> </td>=20
...

What it renders like in a browser: amazon_email_example

Tasks

@grosser, thoughts?

grosser commented 7 years ago

1.6.0