Opened 7 hours ago
Last modified 2 hours ago
#62427 assigned defect (bug)
HTML API: Next tag tag name query is case sensitive
Reported by: | jonsurrell | Owned by: | jonsurrell |
---|---|---|---|
Milestone: | 6.7.1 | Priority: | normal |
Severity: | normal | Version: | 6.6 |
Component: | HTML API | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
The HTML API ::next_tag
method accepts a tag_name
query. The tag name matching should be case-insensitive. Tag names are generally UPPERCASE in the processors, a lower or mixed case name doesn't make much sense.
<?php // This is OK $processor = WP_HTML_Processor::create_fragment( '<DIV>' ); assert( $processor->next_tag( 'div' ) ); // This is OK $processor = WP_HTML_Processor::create_fragment( '<DIV>' ); assert( $processor->next_tag( array( 'breadcrumbs' => array( 'div' ) ) ) ); // This does not work but should $processor = WP_HTML_Processor::create_fragment( '<DIV>' ); assert( $processor->next_tag( array( 'tag_name' => 'div' ) ) ); // AssertionError!
This is also supported in the tag processor case-insensitively:
<?php $processor = new WP_HTML_Tag_Processor( '<section><DIV>' ); assert( $processor->next_tag( array( 'tag_name' => 'div' ) ) ); $processor->get_tag(); // "DIV"
Change History (3)
This ticket was mentioned in PR #7754 on WordPress/wordpress-develop by @jonsurrell.
7 hours ago
#1
- Keywords has-patch has-unit-tests added
@jonsurrell commented on PR #7754:
2 hours ago
#3
As far as I can tell this was an oversight. I can't think of a reason _to_ match this case-sensitively.
I suspect this was not noticed because the shorthand exists for the next tag with a tag name in the HTML Processor: next_tag( 'div' )
.
Under the hood that uses next_tag( array( 'breadcrumbs' => array( 'div' ) ) )
:
And _that_ is handled correctly by the matches_breadcrumbs
function:
(I had included a change in this patch to change the shorthand implementation to use tag_name
instead of breadcrumbs
, but removed that as out-of-scope for a bugfix.)
Trac ticket: https://core.trac.wordpress.org/ticket/62427