Make WordPress Core

Changeset 59535 for branches/6.7


Ignore:
Timestamp:
12/18/2024 06:38:58 PM (20 months ago)
Author:
desrosj
Message:

HTML API: Use case insensitive tag_name comparison in ::next_tag.

The HTML API ::next_tag method now performs case-insensitive matching when searching for tags by name. For example, searching for 'DIV' will match both '<div>' and '<DIV>' tags.

Reviewed by desrosj.
Merges [59422] to the 6.7 branch.

Props jonsurrell, dmsnell, czapla.
Fixes #62427.

Location:
branches/6.7
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/6.7

  • branches/6.7/src/wp-includes/html-api/class-wp-html-processor.php

    r59411 r59535  
    558558                }
    559559
     560                if ( isset( $query['tag_name'] ) ) {
     561                        $query['tag_name'] = strtoupper( $query['tag_name'] );
     562                }
     563
    560564                $needs_class = ( isset( $query['class_name'] ) && is_string( $query['class_name'] ) )
    561565                        ? $query['class_name']
  • branches/6.7/tests/phpunit/tests/html-api/wpHtmlProcessor.php

    r59248 r59535  
    883883                $this->assertTrue( $processor->is_tag_closer() );
    884884        }
     885
     886        /**
     887         * Ensure that lowercased tag_name query matches tags case-insensitively.
     888         *
     889         * @group 62427
     890         */
     891        public function test_next_tag_lowercase_tag_name() {
     892                // The upper case <DIV> is irrelevant but illustrates the case-insentivity.
     893                $processor = WP_HTML_Processor::create_fragment( '<section><DIV>' );
     894                $this->assertTrue( $processor->next_tag( array( 'tag_name' => 'div' ) ) );
     895
     896                // The upper case <RECT> is irrelevant but illustrates the case-insentivity.
     897                $processor = WP_HTML_Processor::create_fragment( '<svg><RECT>' );
     898                $this->assertTrue( $processor->next_tag( array( 'tag_name' => 'rect' ) ) );
     899        }
    885900}
Note: See TracChangeset for help on using the changeset viewer.