Make WordPress Core

Changeset 61796

Timestamp:
03/03/2026 02:59:01 PM (37 hours ago)
Author:
jonsurrell
Message:

HTML API: Check tag namespace in ::set_modifiable_text().

The method should only apply to special "atomic" HTML tags like SCRIPT or TEXTAREA. ::set_modifiable_text() should not apply to tags with the same name in other namespaces.

Developed in https://github.com/WordPress/wordpress-develop/pull/11083.

Props jonsurrell, dmsnell, westonruter.
Fixes #64751.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/html-api/class-wp-html-tag-processor.php

    r61793 r61796  
    38183818        }
    38193819
    3820         if ( self::STATE_MATCHED_TAG !== $this->parser_state ) {
     3820        /*
     3821         * The rest of this function handles modifiable text for special "atomic" HTML elements.
     3822         * Only tags in the HTML namespace should be processed.
     3823         */
     3824        if (
     3825            self::STATE_MATCHED_TAG !== $this->parser_state ||
     3826            'html' !== $this->get_namespace()
     3827        ) {
    38213828            return false;
    38223829        }
  • trunk/tests/phpunit/tests/html-api/wpHtmlProcessorModifiableText.php

    r61754 r61796  
    2525     * @param string $expected_html    Expected HTML output.
    2626     */
    27     public function test_modifiable_text_special_textarea( string $set_text, string $expected_html ) {
     27    public function test_modifiable_text_special_textarea( string $set_text, string $expected_html ) {
    2828        $processor = WP_HTML_Processor::create_fragment( '<textarea></textarea>' );
    2929        $processor->next_token();
     
    5151     * Data provider.
    5252     *
    53      * @return array[]
     53     * @return array
    5454     */
    55     public static function data_modifiable_text_special_textarea() {
     55    public static function data_modifiable_text_special_textarea() {
    5656        return array(
    5757            'Leading newline'                   => array(
     
    6969        );
    7070    }
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
     100
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110
     111
     112
     113
     114
     115
     116
     117
     118
     119
     120
     121
     122
     123
     124
     125
    71126}
  • trunk/tests/phpunit/tests/html-api/wpHtmlTagProcessorModifiableText.php

    r61754 r61796  
    645645     * @ticket 64609
    646646     */
    647     public function test_modifiable_text_special_textarea() {
     647    public function test_modifiable_text_special_textarea() {
    648648        $processor = new WP_HTML_Tag_Processor( '<textarea></textarea>' );
    649649        $processor->next_token();
     
    665665        );
    666666    }
     667
     668
     669
     670
     671
     672
     673
     674
     675
     676
     677
     678
     679
     680
     681
     682
     683
     684
     685
     686
     687
     688
     689
     690
     691
     692
     693
     694
     695
     696
     697
     698
     699
     700
     701
     702
     703
     704
     705
     706
     707
     708
     709
     710
     711
     712
     713
     714
     715
     716
     717
     718
     719
     720
     721
     722
    667723}
Note: See TracChangeset for help on using the changeset viewer.