Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix regression in previous commit which broke parsing for json string…

…s inside :val() and :contains()
  • Loading branch information...
commit 24d543344b7fe09c8665daa2fd274985c43e4404 1 parent e3ce679
@lloyd authored
Showing with 11 additions and 10 deletions.
  1. +1 −1  JSONSelect.md
  2. +9 −8 src/jsonselect.js
  3. +1 −1  src/test/tests
View
2  JSONSelect.md
@@ -206,7 +206,7 @@ See [https://github.com/lloyd/JSONSelectTests](https://github.com/lloyd/JSONSele
In no particular order.
* [http://json.org/](http://json.org/)
- * [http://www.w3.org/TR/css3-selectors/]( * http://www.w3.org/TR/css3-selectors/)
+ * [http://www.w3.org/TR/css3-selectors/](http://www.w3.org/TR/css3-selectors/)
* [http://ejohn.org/blog/selectors-that-people-actually-use/](http://ejohn.org/blog/selectors-that-people-actually-use/)
* [http://shauninman.com/archive/2008/05/05/css\_qualified\_selectors]( * http://shauninman.com/archive/2008/05/05/css_qualified_selectors)
* [http://snook.ca/archives/html\_and\_css/css-parent-selectors](http://snook.ca/archives/html_and_css/css-parent-selectors)
View
17 src/jsonselect.js
@@ -49,7 +49,8 @@
psc: 1, // pseudo class
psf: 2, // pseudo class function
typ: 3, // type
- str: 4 // string
+ str: 4, // string
+ ide: 5 // identifiers (or "classes", stuff after a dot)
};
// The primary lexing regular expression in jsonselect
@@ -67,12 +68,12 @@
"(:(?:nth-child|nth-last-child|has|expr|val|contains))|" +
// (6) bogusly named pseudo something or others
"(:\\w+)|" +
- // (7) JSON strings
- "\\.(\\\"(?:[^\\\\]|\\\\[^\\\"])*\\\")|" +
+ // (7 & 8) identifiers and JSON strings
+ "(?:(\\.)?(\\\"(?:[^\\\\]|\\\\[^\\\"])*\\\"))|" +
// (8) bogus JSON strings missing a trailing quote
"(\\\")|" +
// (9) identifiers (unquoted)
- "\\.((?:[_a-zA-Z]|[^\\0-\\0177]|\\\\[^\\r\\n\\f0-9a-fA-F])(?:[_a-zA-Z0-9\\-]|[^\\u0000-\\u0177]|(?:\\\\[^\\r\\n\\f0-9a-fA-F]))*)" +
+ "\\.((?:[_a-zA-Z]|[^\\0-\\0177]|\\\\[^\\r\\n\\f0-9a-fA-F])(?:[_a-zA-Z0-9\\-]|[^\\u0000-\\u0177]|(?:\\\\[^\\r\\n\\f0-9a-fA-F]))*)" +
")"
);
@@ -90,9 +91,9 @@
else if (m[4]) a = [off, toks.psc, m[0]];
else if (m[5]) a = [off, toks.psf, m[0]];
else if (m[6]) te("upc");
- else if (m[7]) a = [off, toks.str, jsonParse(m[7])];
- else if (m[8]) te("ujs");
- else if (m[9]) a = [off, toks.str, m[9].replace(/\\([^\r\n\f0-9a-fA-F])/g,"$1")];
+ else if (m[8]) a = [off, m[7] ? toks.ide : toks.str, jsonParse(m[8])];
+ else if (m[9]) te("ujs");
+ else if (m[10]) a = [off, toks.ide, m[10].replace(/\\([^\r\n\f0-9a-fA-F])/g,"$1")];
return a;
}
@@ -320,7 +321,7 @@
while (true) {
if (l === undefined) {
break;
- } else if (l[1] === toks.str) {
+ } else if (l[1] === toks.ide) {
if (s.id) te("nmi");
s.id = l[2];
} else if (l[1] === toks.psc) {
2  src/test/tests
@@ -1 +1 @@
-Subproject commit 8fc76c39b344f8a26b9de57160f50271cc307bdb
+Subproject commit 57af546cc5759f9c9f62bf446b140b80f4c958b9
Please sign in to comment.
Something went wrong with that request. Please try again.