Skip to content

Commit e9bbdbf

Browse files
dmsnellwestonrutersirreal
committed
Add explanatory comments and update ticket number.
Co-authored-by: Weston Ruter <westonruter@git.wordpress.org> Co-authored-by: Jon Surrell <jonsurrell@git.wordpress.org>
1 parent e00ab01 commit e9bbdbf

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

src/wp-includes/html-api/class-wp-html-processor.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,16 @@ private function step_in_body() {
633633
$this->reconstruct_active_formatting_elements();
634634

635635
$current_token = $this->bookmarks[ $this->state->current_token->bookmark_name ];
636+
637+
/*
638+
* > A character token that is U+0000 NULL
639+
*
640+
* Any successive sequence of NULL bytes is ignored and won't
641+
* trigger active format reconstruction. Therefore, if the text
642+
* only comprises NULL bytes then the token should be ignored
643+
* here, but if there are any other characters in the stream
644+
* the active formats should be reconstructed.
645+
*/
636646
if (
637647
1 <= $current_token->length &&
638648
"\x00" === $this->html[ $current_token->start ] &&

tests/phpunit/tests/html-api/wpHtmlSupportRequiredActiveFormatReconstruction.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ class Tests_HtmlApi_WpHtmlSupportRequiredActiveFormatReconstruction extends WP_U
1717
* Ensures that active formats are properly reconstructed when visiting text nodes,
1818
* verifying that the proper breadcrumbs are maintained when scanning through HTML.
1919
*
20-
* @ticket {TICKET_NUMBER}
21-
*
22-
* @since 6.5.0
20+
* @ticket 60455
2321
*/
2422
public function test_reconstructs_active_formats_on_text_nodes() {
2523
$processor = WP_HTML_Processor::create_fragment( '<p><b>One<span><p>Two' );
@@ -41,6 +39,12 @@ public function test_reconstructs_active_formats_on_text_nodes() {
4139
* second text node but fail to reconstruct the implicitly-closed B element.
4240
* The other way is to fail to abort when encountering the second text node
4341
* because the kind of active format reconstruction isn't supported.
42+
*
43+
* At the time of writing this test, the HTML Processor bails whenever it
44+
* needs to reconstruct active formats, unless there are no active formats.
45+
* To ensure that this test properly works once that support is expanded,
46+
* it's written to verify both circumstances. Once support is added, this
47+
* can be simplified to only contain the first clause of the conditional.
4448
*/
4549

4650
if ( $processor->next_token() ) {

0 commit comments

Comments
 (0)