Skip to content

Commit 2e83211

Browse files
jsprifb55
authored andcommittedJan 20, 2018
Quoted attributes regex fix (#17)
* Fixed newline characters inside of quoted attributes * Added test * Swapped to negation selector
1 parent fd6b9f6 commit 2e83211

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed
 

‎index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ module.exports = parse;
55
var re_name = /^(?:\\.|[\w\-\u00c0-\uFFFF])+/,
66
re_escape = /\\([\da-f]{1,6}\s?|(\s)|.)/ig,
77
//modified version of https://github.com/jquery/sizzle/blob/master/src/sizzle.js#L87
8-
re_attr = /^\s*((?:\\.|[\w\u00c0-\uFFFF\-])+)\s*(?:(\S?)=\s*(?:(['"])(.*?)\3|(#?(?:\\.|[\w\u00c0-\uFFFF\-])*)|)|)\s*(i)?\]/;
8+
re_attr = /^\s*((?:\\.|[\w\u00c0-\uFFFF\-])+)\s*(?:(\S?)=\s*(?:(['"])([^]*?)\3|(#?(?:\\.|[\w\u00c0-\uFFFF\-])*)|)|)\s*(i)?\]/;
99

1010
var actionTypes = {
1111
__proto__: null,

‎tests/test.js

+15
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,21 @@ var tests = [
250250
],
251251
"quoted attribute with spaces"
252252
],
253+
[
254+
"[value=\"\nsome text\n\"]",
255+
[
256+
[
257+
{
258+
"type": "attribute",
259+
"name": "value",
260+
"action": "equals",
261+
"value": "\nsome text\n",
262+
"ignoreCase": false
263+
}
264+
]
265+
],
266+
"quoted attribute with internal newline"
267+
],
253268
[
254269
"[name=foo\\.baz]",
255270
[

0 commit comments

Comments
 (0)