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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).

### Fixed

- Fix PHP notice caused by parsing invalid color values having less than 6 characters (#485)
- Fix (regression) failure to parse at-rules with strict parsing (#456)

## 8.5.0
Expand Down
9 changes: 8 additions & 1 deletion src/Value/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,19 @@ public static function parse(ParserState $oParserState, $bIgnoreCase = false)
$oParserState->currentLine()
),
];
} else {
} elseif ($oParserState->strlen($sValue) === 6) {
$aColor = [
'r' => new Size(intval($sValue[0] . $sValue[1], 16), null, true, $oParserState->currentLine()),
'g' => new Size(intval($sValue[2] . $sValue[3], 16), null, true, $oParserState->currentLine()),
'b' => new Size(intval($sValue[4] . $sValue[5], 16), null, true, $oParserState->currentLine()),
];
} else {
throw new UnexpectedTokenException(
'Invalid hex color value',
$sValue,
'custom',
$oParserState->currentLine()
);
}
} else {
$sColorMode = $oParserState->parseIdentifier(true);
Expand Down
2 changes: 2 additions & 0 deletions tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ public function colorParsing()
'l' => new Size(220.0, '%', true, $oColor->getLineNo()),
'a' => new Size(0000.3, null, true, $oColor->getLineNo()),
], $oColor->getColor());
$aColorRule = $oRuleSet->getRules('outline-color');
self::assertEmpty($aColorRule);
}
}
foreach ($oDoc->getAllValues('color') as $sColor) {
Expand Down
1 change: 1 addition & 0 deletions tests/fixtures/colortest.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#yours {
background-color: hsl(220, 10%, 220%);
background-color: hsla(220, 10%, 220%, 0.3);
outline-color: #22;
}

#variables {
Expand Down