Skip to content

Commit 2ae1a6d

Browse files
committed
Block Processor: Improve comment end search behavior.
Prevent `WP_Block_Processor::find_html_comment_end()` from repeatedly scanning some spans that cannot contain a comment end. Developed in: WordPress#13679 Props jonsurrell, dmsnell. See #66138. git-svn-id: https://develop.svn.wordpress.org/trunk@63911 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 6b08132 commit 2ae1a6d

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

‎src/wp-includes/class-wp-block-processor.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,7 @@ private function find_html_comment_end( int $comment_starting_at, int $search_en
13561356
return $closer_must_be_at + 1;
13571357
}
13581358

1359-
++$now_at;
1359+
$now_at = $closer_must_be_at;
13601360
}
13611361

13621362
return $search_end;

‎tests/phpunit/tests/block-processor/wpBlockProcessor.php‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ public function test_rejects_once_errored_out() {
242242
* Verifies that corrupted block delimiters are not matched as delimiters.
243243
*
244244
* @ticket 61401
245+
* @ticket 66138
245246
*
246247
* @dataProvider data_invalid_block_delimiters_as_html_comments
247248
*
@@ -299,6 +300,12 @@ public static function data_invalid_block_delimiters_as_html_comments() {
299300
'Malformed block namespace' => array( '<!-- wp:3more/block -->' ),
300301
'Malformed block name' => array( '<!-- wp:core/paragraph/variation -->' ),
301302
'Invalid block name characters' => array( '<!-- wp:core/32-block -->' ),
303+
'Dash run' => array( '<!--x-----y-->' ),
304+
'Dash run then bang' => array( '<!--x---!y-->' ),
305+
'Bang then dashes' => array( '<!--x--!-y-->' ),
306+
'Dash run then bang closer' => array( '<!--x---!>' ),
307+
'Bang then dash then closer' => array( '<!--x--!-->' ),
308+
'Long dash run' => array( '<!--x' . str_repeat( '-', 50000 ) . 'y-->' ),
302309
);
303310
}
304311

0 commit comments

Comments
 (0)