Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser breaks when an end parenthesis occurs in a quoted string #56

Closed
papandreou opened this issue May 1, 2013 · 2 comments
Closed

Comments

@papandreou
Copy link
Contributor

require('cssom').parse("body{background-image: url(')');}")

Output:

Error: Unmatched ' (line 1, char 30)
    at CSSOM.parse.parseError (/home/andreas/work/CSSOM/lib/parse.js:54:15)
    at Object.parse (/home/andreas/work/CSSOM/lib/parse.js:101:6)
    at repl:1:25
    at REPLServer.self.eval (repl.js:109:21)
    at Interface.<anonymous> (repl.js:248:12)
    at Interface.EventEmitter.emit (events.js:96:17)
    at Interface._onLine (readline.js:200:10)
    at Interface._line (readline.js:518:8)
    at Interface._ttyWrite (readline.js:736:14)
    at ReadStream.onkeypress (readline.js:97:10)

It's caused by parse.js handling ( in a CSS value in a rather naive way: index is advanced to the first occurrence of ) regardless of whether that's inside a quoted string, eg. url('...)') or url("...)").

The error occurs "in real life" with this file: https://github.com/ajaxorg/ace/blob/master/lib/ace/css/editor.css#L305

@tomgenoni
Copy link

Similar example that throws error:

 .foo {-ms-filter: unqoute('alpha(Opacity=75)');}

@NV
Copy link
Owner

NV commented Nov 26, 2015

Fixed for:

body{background-image: url(')');}

http://nv.github.io/CSSOM/docs/parse.html#css=body%7Bbackground-image%3A%20url(')')%3B%7D

.foo {-ms-filter: unqoute('alpha(Opacity=75)');}

http://nv.github.io/CSSOM/docs/parse.html#css=.foo%20%7B-ms-filter%3A%20unqoute('alpha(Opacity%3D75)')%3B%7D

I haven't done any real-world testing. Please let me know if I broke something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants