jotform / css.js

A lightweight, battle tested, fast, CSS parser in JavaScript
https://medium.com/jotform-form-builder/writing-a-css-parser-in-javascript-3ecaa1719a43
MIT License
427 stars 63 forks source link

breaks on semicolon after data:image #28

Open loopmode opened 4 years ago

loopmode commented 4 years ago

Hi. I just observed an issue where background: url('data:image/svg+xml;charset=utf-8,<svg%20version%... becomes invalid CSS due to a linebreak after semicolon:

 background: url('data:image/svg+xml;
    charset=utf-8,<svg%20version%...

(This is in the "funky" theme of Prism.js)

I have a very limited scope in my project so I will "fix" the problem using a simple string operation, but I wanted to report the case here.

I don't believe I'll have time for an actual fix and PR, but will report if I do.

In case somebody stumbles across this and needs a naive but simple solution, the workaround for my particular example goes something like this:

  const prefixedCss = parser
    .getCSSForEditor(namespaced)
    // see https://github.com/jotform/css.js/issues/28
    .replace(/svg\+xml;\n    /, 'svg+xml;');