Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7de8f99

Browse filesBrowse files
committed
[CssSelector] Fix escape patterns
1 parent a507b80 commit 7de8f99
Copy full SHA for 7de8f99

File tree

Expand file treeCollapse file tree

2 files changed

+14
-4
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-4
lines changed

‎src/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerPatterns.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/CssSelector/Parser/Tokenizer/TokenizerPatterns.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,22 @@ public function __construct()
4949
$this->identifierPattern = '-?(?:'.$this->nmStartPattern.')(?:'.$this->nmCharPattern.')*';
5050
$this->hashPattern = '#((?:'.$this->nmCharPattern.')+)';
5151
$this->numberPattern = '[+-]?(?:[0-9]*\.[0-9]+|[0-9]+)';
52-
$this->quotedStringPattern = '([^\n\r\f%s]|'.$this->stringEscapePattern.')*';
52+
$this->quotedStringPattern = '([^\n\r\f\\\\%s]|'.$this->stringEscapePattern.')*';
5353
}
5454

5555
public function getNewLineEscapePattern(): string
5656
{
57-
return '~^'.$this->newLineEscapePattern.'~';
57+
return '~'.$this->newLineEscapePattern.'~';
5858
}
5959

6060
public function getSimpleEscapePattern(): string
6161
{
62-
return '~^'.$this->simpleEscapePattern.'~';
62+
return '~'.$this->simpleEscapePattern.'~';
6363
}
6464

6565
public function getUnicodeEscapePattern(): string
6666
{
67-
return '~^'.$this->unicodeEscapePattern.'~i';
67+
return '~'.$this->unicodeEscapePattern.'~i';
6868
}
6969

7070
public function getIdentifierPattern(): string

‎src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,16 @@ public function getParserTestData()
138138
['div:not(div.foo)', ['Negation[Element[div]:not(Class[Element[div].foo])]']],
139139
['td ~ th', ['CombinedSelector[Element[td] ~ Element[th]]']],
140140
['.foo[data-bar][data-baz=0]', ["Attribute[Attribute[Class[Element[*].foo][data-bar]][data-baz = '0']]"]],
141+
['div#foo\.bar', ['Hash[Element[div]#foo.bar]']],
142+
['div.w-1\/3', ['Class[Element[div].w-1/3]']],
143+
['#test\:colon', ['Hash[Element[*]#test:colon]']],
144+
[".a\xc1b", ["Class[Element[*].a\xc1b]"]],
145+
// unicode escape: \22 == "
146+
['*[aval="\'\22\'"]', ['Attribute[Element[*][aval = \'\'"\'\']]']],
147+
['*[aval="\'\22 2\'"]', ['Attribute[Element[*][aval = \'\'"2\'\']]']],
148+
// unicode escape: \20 == (space)
149+
['*[aval="\'\20 \'"]', ['Attribute[Element[*][aval = \'\' \'\']]']],
150+
["*[aval=\"'\\20\r\n '\"]", ['Attribute[Element[*][aval = \'\' \'\']]']],
141151
];
142152
}
143153

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.