Skip to content

Commit

Permalink
Ensure that wildcards match the current tag as well
Browse files Browse the repository at this point in the history
  • Loading branch information
dmsnell authored and ockham committed Sep 26, 2023
1 parent e20baa4 commit cd79cdd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/wp-includes/html-api/class-wp-html-processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ public function matches_breadcrumbs( $breadcrumbs ) {
// Start at the last crumb.
$crumb = end( $breadcrumbs );

if ( $this->get_tag() !== strtoupper( $crumb ) ) {
if ( '*' !== $crumb && $this->get_tag() !== strtoupper( $crumb ) ) {
return false;
}

Expand Down
4 changes: 4 additions & 0 deletions tests/phpunit/tests/html-api/wpHtmlProcessorBreadcrumbs.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,10 @@ public function data_html_with_breadcrumbs_of_various_specificity() {
'Inner P no wildcard' => array( '<div><span><figure></p target></figure></span></div>', array( 'span', 'p' ), false ),
'Full specification (P)' => array( '<div><span><figure></p target></figure></span></div>', array( 'html', 'body', 'div', 'span', 'figure', 'p' ), false ),
'Invalid Full specification (P)' => array( '<div><span><figure></p target></figure></span></div>', array( 'html', 'div', 'span', 'figure', 'p' ), false ),

// Test wildcard behaviors.
'Single wildcard element' => array( '<figure><code><div><p><span><img target></span></p></div></code></figure>', array( '*' ), true ),
'Child of wildcard element' => array( '<figure><code><div><p><span><img target></span></p></div></code></figure>', array( 'SPAN', '*' ), true ),
);
}

Expand Down

0 comments on commit cd79cdd

Please sign in to comment.