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
2 changes: 1 addition & 1 deletion components/DataLiberation/CSS/class-cssprocessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
12 changes: 11 additions & 1 deletion components/DataLiberation/Tests/CSSProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}
Loading