Skip to content

Commit

Permalink
Quoted attributes regex fix (#17)
Browse files Browse the repository at this point in the history
* Fixed newline characters inside of quoted attributes

* Added test

* Swapped to negation selector
  • Loading branch information
jspri authored and fb55 committed Jan 20, 2018
1 parent fd6b9f6 commit 2e83211
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = parse;
var re_name = /^(?:\\.|[\w\-\u00c0-\uFFFF])+/,
re_escape = /\\([\da-f]{1,6}\s?|(\s)|.)/ig,
//modified version of https://github.com/jquery/sizzle/blob/master/src/sizzle.js#L87
re_attr = /^\s*((?:\\.|[\w\u00c0-\uFFFF\-])+)\s*(?:(\S?)=\s*(?:(['"])(.*?)\3|(#?(?:\\.|[\w\u00c0-\uFFFF\-])*)|)|)\s*(i)?\]/;
re_attr = /^\s*((?:\\.|[\w\u00c0-\uFFFF\-])+)\s*(?:(\S?)=\s*(?:(['"])([^]*?)\3|(#?(?:\\.|[\w\u00c0-\uFFFF\-])*)|)|)\s*(i)?\]/;

var actionTypes = {
__proto__: null,
Expand Down
15 changes: 15 additions & 0 deletions tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,21 @@ var tests = [
],
"quoted attribute with spaces"
],
[
"[value=\"\nsome text\n\"]",
[
[
{
"type": "attribute",
"name": "value",
"action": "equals",
"value": "\nsome text\n",
"ignoreCase": false
}
]
],
"quoted attribute with internal newline"
],
[
"[name=foo\\.baz]",
[
Expand Down

0 comments on commit 2e83211

Please sign in to comment.