Make WordPress Core


Ignore:
Timestamp:
02/17/2024 03:26:43 PM (10 months ago)
Author:
swissspidy
Message:

Interactivity API: Skip instead of bail out if HTML contains SVG or MATH.

Addresses an issue with server-side processing of directives when there is e.g. an SVG icon a navigation menu.

Props cbravobernal, westonruter, dmsnell, swissspidy.
Fixes #60517.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/interactivity-api/wpInteractivityAPIDirectivesProcessor.php

    r57563 r57649  
    1212 * @coversDefaultClass WP_Interactivity_API_Directives_Processor
    1313 */
    14 class Tests_WP_Interactivity_API_Directives_Processor extends WP_UnitTestCase {
     14class Tests_Interactivity_API_WpInteractivityAPIDirectivesProcessor extends WP_UnitTestCase {
    1515    /**
    1616     * Tests the `get_content_between_balanced_template_tags` method on template
     
    779779        $this->assertFalse( $p->next_balanced_tag_closer_tag() );
    780780    }
     781
     782    /**
     783     * Tests that skip_to_tag_closer skips to the next tag,
     784     * independant of the content.
     785     *
     786     * @ticket 60517
     787     *
     788     * @covers ::skip_to_tag_closer
     789     */
     790    public function test_skip_to_tag_closer() {
     791        $content = '<div><span>Not closed</div>';
     792        $p       = new WP_Interactivity_API_Directives_Processor( $content );
     793        $p->next_tag();
     794        $this->assertTrue( $p->skip_to_tag_closer() );
     795        $this->assertTrue( $p->is_tag_closer() );
     796        $this->assertEquals( 'DIV', $p->get_tag() );
     797    }
     798
     799    /**
     800     * Tests that skip_to_tag_closer does not skip to the
     801     * next tag if there is no closing tag.
     802     *
     803     * @ticket 60517
     804     *
     805     * @covers ::skip_to_tag_closer
     806     */
     807    public function test_skip_to_tag_closer_bails_not_closed() {
     808        $content = '<div>Not closed parent';
     809        $p       = new WP_Interactivity_API_Directives_Processor( $content );
     810        $p->next_tag();
     811        $this->assertFalse( $p->skip_to_tag_closer() );
     812    }
     813
     814    /**
     815     * Tests that skip_to_tag_closer does not skip to the next
     816     * tag if the closing tag is different from the current tag.
     817     *
     818     * @ticket 60517
     819     *
     820     * @covers ::skip_to_tag_closer
     821     */
     822    public function test_skip_to_tag_closer_bails_different_tags() {
     823        $content = '<div></span>';
     824        $p       = new WP_Interactivity_API_Directives_Processor( $content );
     825        $p->next_tag();
     826        $this->assertFalse( $p->skip_to_tag_closer() );
     827    }
    781828}
Note: See TracChangeset for help on using the changeset viewer.