diff --git a/components/DataLiberation/CSS/class-cssprocessor.php b/components/DataLiberation/CSS/class-cssprocessor.php index 0265fc2e..cacb48b4 100644 --- a/components/DataLiberation/CSS/class-cssprocessor.php +++ b/components/DataLiberation/CSS/class-cssprocessor.php @@ -1500,7 +1500,7 @@ private function consume_ident_codepoint( $at ): int { * @return int The number of bytes consumed. */ private function consume_ident_start_codepoint( $at ): int { - if ( $at > $this->length ) { + if ( $at >= $this->length ) { return 0; } diff --git a/components/DataLiberation/Tests/CSSProcessorTest.php b/components/DataLiberation/Tests/CSSProcessorTest.php index 900fcece..ed164ac2 100644 --- a/components/DataLiberation/Tests/CSSProcessorTest.php +++ b/components/DataLiberation/Tests/CSSProcessorTest.php @@ -1530,5 +1530,15 @@ public function test_set_token_with_invalid_utf8_sequence(): void { $this->assertSame( "background: url(\"\xC0.jpg\");", $updated ); } - + /** + * Test bounds check when consuming and ident start token. + */ + public function test_ident_start_codepoint_bounds_check(): void { + $processor = CSSProcessor::create( '-' ); + $actual_tokens = $this->collect_tokens( $processor, array( 'type', 'raw' ) ); + $expected_tokens = array( + array( 'type' => CSSProcessor::TOKEN_DELIM, 'raw' => '-' ), + ); + $this->assertSame( $expected_tokens, $actual_tokens ); + } }