@@ -2887,11 +2887,11 @@ public static function data_updating_attributes_in_malformed_html() {
28872887 ),
28882888 'HTML tag opening inside attribute value ' => array (
28892889 'input ' => '<pre id="<code" class="wp-block-code <code is poetry>"><code>This <is> a <strong is="true">thing.</code></pre><span>test</span> ' ,
2890- 'expected ' => '<pre foo="bar" id="<code" class="wp-block-code <code is poetry& gt; firstTag"><code class="secondTag">This <is> a <strong is="true">thing.</code></pre><span>test</span> ' ,
2890+ 'expected ' => '<pre foo="bar" id="<code" class="wp-block-code <code is poetry> firstTag"><code class="secondTag">This <is> a <strong is="true">thing.</code></pre><span>test</span> ' ,
28912891 ),
28922892 'HTML tag brackets in attribute values and data markup ' => array (
28932893 'input ' => '<pre id="<code->-block->" class="wp-block-code <code is poetry>"><code>This <is> a <strong is="true">thing.</code></pre><span>test</span> ' ,
2894- 'expected ' => '<pre foo="bar" id="<code->-block->" class="wp-block-code <code is poetry& gt; firstTag"><code class="secondTag">This <is> a <strong is="true">thing.</code></pre><span>test</span> ' ,
2894+ 'expected ' => '<pre foo="bar" id="<code->-block->" class="wp-block-code <code is poetry> firstTag"><code class="secondTag">This <is> a <strong is="true">thing.</code></pre><span>test</span> ' ,
28952895 ),
28962896 'Single and double quotes in attribute value ' => array (
28972897 'input ' => '<p title="Demonstrating how to use single quote ( \') and double quote (")"><span>test</span> ' ,
@@ -3028,6 +3028,50 @@ public static function data_updating_attributes_in_malformed_html() {
30283028 );
30293029 }
30303030
3031+ /**
3032+ * @ticket 64340
3033+ */
3034+ public function test_class_changes_produce_correct_html () {
3035+ $ processor = new WP_HTML_Tag_Processor ( '<div class="&"> ' );
3036+ $ processor ->next_tag ();
3037+
3038+ $ processor ->add_class ( '" ' );
3039+ $ processor ->get_updated_html ();
3040+
3041+ $ processor ->add_class ( 'OK ' );
3042+ $ processor ->get_updated_html ();
3043+
3044+ $ this ->assertTrue ( $ processor ->has_class ( '& ' ), 'Missing expected "&" class. ' );
3045+ $ this ->assertTrue ( $ processor ->has_class ( '" ' ), 'Missing expected \'" \' class. ' );
3046+ $ this ->assertTrue ( $ processor ->has_class ( 'OK ' ), 'Missing expected "OK" class. ' );
3047+
3048+ $ expected = '<div class="& " OK"> ' ;
3049+ $ this ->assertEqualHTML (
3050+ $ expected ,
3051+ $ processor ->get_updated_html (),
3052+ '<body> ' ,
3053+ 'HTML was not correctly updated after adding classes. '
3054+ );
3055+
3056+ $ processor ->remove_class ( '& ' );
3057+ $ processor ->get_updated_html ();
3058+
3059+ $ processor ->remove_class ( '" ' );
3060+ $ processor ->get_updated_html ();
3061+
3062+ $ this ->assertFalse ( $ processor ->has_class ( '& ' ) );
3063+ $ this ->assertFalse ( $ processor ->has_class ( '" ' ) );
3064+ $ this ->assertTrue ( $ processor ->has_class ( 'OK ' ) );
3065+
3066+ $ expected = '<div class="OK"> ' ;
3067+ $ this ->assertEqualHTML (
3068+ $ expected ,
3069+ $ processor ->get_updated_html (),
3070+ '<body> ' ,
3071+ 'HTML was not correctly updated after removing classes. '
3072+ );
3073+ }
3074+
30313075 /**
30323076 * @covers WP_HTML_Tag_Processor::next_tag
30333077 */
0 commit comments