rstacruz / sinatra-assetpack

Package your assets transparently in Sinatra.
http://ricostacruz.com/sinatra-assetpack/
MIT License
542 stars 96 forks source link

Skip CSS preprocessing for malformed URIs #167

Closed chancerussell closed 10 years ago

chancerussell commented 10 years ago

The regex in css.rb that checks for URLs (for cache busting?) will match some URLs that URI.parse considers invalid. This came up with a file from zurb/foundation that contained a space in a data:image URI. SASS and browsers seem to handle the space fine, but URI.parse throws an InvalidURIError.

My solution was to wrap the call and return the match unchanged if InvalidURIError is thrown. Another solution might be to change '(.?)' in the regex to '(\S?)', but that would only fix the issue with whitespace--it seems preferable to just pass any string that URI.parse can't handle unchanged, then catch it in SASS if it's actually going to cause a problem.

Pull request #152 attempts to fix the same issue, but would skip anything where the url starts with "data:", which doesn't seem like what we want to do.

I've also added tests to preproc_test.rb for the fix, and a bad_uri.scss file that contains data that shows the issue.

j15e commented 10 years ago

Seems perfect, thanks for providing new test too!

Could you squash commits "Corrected typo in test stub method name" and "Fixed misindentation" before I merge?

flajann2 commented 10 years ago

Thanks for the quick response on this issue.

j15e commented 10 years ago

I am working on a new releasing but having issue with signing the gem, should be released soon.

j15e commented 10 years ago

Just published 0.3.3