[wp-trac] [WordPress Trac] #60392: HTML API: Tag processor no longer visits all closing tags

WordPress Trac noreply at wordpress.org
Wed Jan 31 01:32:28 UTC 2024


#60392: HTML API: Tag processor no longer visits all closing tags
--------------------------+---------------------
 Reporter:  westonruter   |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  6.5
Component:  HTML API      |     Version:  trunk
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |     Focuses:
--------------------------+---------------------
Description changed by westonruter:

Old description:

> I just discovered that the HTML Tag Processor is no longer visiting all
> closing tags.
>
> This issue was introduced in r57348 as part of #60170.
>
> Here is a test case:
>
> {{{#!php
> <?php
> <?php
>
> $html = '
>         <html>
>                 <head>
>                         <title>Greeting</title>
>                 </head>
>                 <body>
>                         <p>Hello world!</p>
>                 </body>
>         </html>
> ';
>
> $p = new WP_HTML_Tag_Processor( $html );
>
> $found_closing_title_tag = false;
> while ( $p->next_tag( array( 'tag_closers' => 'visit' ) ) ) {
>         if ( $p->is_tag_closer() && 'TITLE' === $p->get_tag() ) {
>                 $found_closing_head_tag = true;
>         }
> }
>
> echo ( $found_closing_title_tag ? 'GOOD' : 'BAD' ) . PHP_EOL;
> }}}
>
> I've noticed this also happen for `STYLE` and `SCRIPT` tags in the
> `HEAD`, in addition to `TITLE`.
>
> Before the commit, this outputs `GOOD` but after the commit it outputs
> `BAD`.

New description:

 I just discovered that the HTML Tag Processor is no longer visiting all
 closing tags.

 This issue was introduced in r57348 as part of #60170.

 Here is a test case:

 {{{#!php
 <?php

 $html = '
         <html>
                 <head>
                         <title>Greeting</title>
                 </head>
                 <body>
                         <p>Hello world!</p>
                 </body>
         </html>
 ';

 $p = new WP_HTML_Tag_Processor( $html );

 $found_closing_title_tag = false;
 while ( $p->next_tag( array( 'tag_closers' => 'visit' ) ) ) {
         if ( $p->is_tag_closer() && 'TITLE' === $p->get_tag() ) {
                 $found_closing_head_tag = true;
         }
 }

 echo ( $found_closing_title_tag ? 'GOOD' : 'BAD' ) . PHP_EOL;
 }}}

 I've noticed this also happen for `STYLE` and `SCRIPT` tags in the `HEAD`,
 in addition to `TITLE`.

 Before the commit, this outputs `GOOD` but after the commit it outputs
 `BAD`.

--

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60392#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list