Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/Sabberworm/CSS/Parsing/ParserState.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ public function parseIdentifier($bIgnoreCase = true) {
}
$sCharacter = null;
while (($sCharacter = $this->parseCharacter(true)) !== null) {
$sResult .= $sCharacter;
if (preg_match('/[a-zA-Z0-9\x{00A0}-\x{FFFF}_-]/Sux', $sCharacter)) {
$sResult .= $sCharacter;
} else {
$sResult .= '\\' . $sCharacter;
}
}
if ($bIgnoreCase) {
$sResult = $this->strtolower($sResult);
Expand Down
6 changes: 6 additions & 0 deletions tests/Sabberworm/CSS/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,12 @@ function testSelectorEscapesInFile() {
$this->assertSame($sExpected, $oDoc->render());
}

function testIdentifierEscapesInFile() {
$oDoc = $this->parsedStructureForFile('identifier-escapes', Settings::create()->withMultibyteSupport(true));
$sExpected = 'div {font: 14px Font Awesome\ 5 Pro;font: 14px Font Awesome\} 5 Pro;font: 14px Font Awesome\; 5 Pro;f\;ont: 14px Font Awesome\; 5 Pro;}';
$this->assertSame($sExpected, $oDoc->render());
}

function testSelectorIgnoresInFile() {
$oDoc = $this->parsedStructureForFile('selector-ignores', Settings::create()->withMultibyteSupport(true));
$sExpected = '.some[selectors-may=\'contain-a-{\'] {}
Expand Down
6 changes: 6 additions & 0 deletions tests/files/identifier-escapes.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
div {
font: 14px Font Awesome\ 5 Pro;
font: 14px Font Awesome\} 5 Pro;
font: 14px Font Awesome\; 5 Pro;
f\;ont: 14px Font Awesome\; 5 Pro;
}