Skip to content

Fix bug in CSS tokenizer #3906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 28, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,10 @@
}
/* phpcs:set Squiz.WhiteSpace.SuperfluousWhitespace ignoreBlankLines false */

// /**
// * This text is in two types of comment: each line is commented out
// * individually, and the whole block is in what looks like a
// * docblock-comment. This sniff should ignore all this text as there
// * is no superfluous white-space here.
// */

Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,10 @@
float: left;
}
/* phpcs:set Squiz.WhiteSpace.SuperfluousWhitespace ignoreBlankLines false */

// /**
// * This text is in two types of comment: each line is commented out
// * individually, and the whole block is in what looks like a
// * docblock-comment. This sniff should ignore all this text as there
// * is no superfluous white-space here.
// */
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function getErrorList($testFile='SuperfluousWhitespaceUnitTest.inc')
8 => 1,
9 => 1,
11 => 1,
25 => 1,
32 => 1,
];
break;
default:
Expand Down
6 changes: 5 additions & 1 deletion src/Tokenizers/CSS.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ public function tokenize($string)

// The first and last tokens are the open/close tags.
array_shift($commentTokens);
array_pop($commentTokens);
$closeTag = array_pop($commentTokens);

while ($closeTag['content'] !== '?'.'>') {
$closeTag = array_pop($commentTokens);
}

if ($leadingZero === true) {
$commentTokens[0]['content'] = substr($commentTokens[0]['content'], 1);
Expand Down