@@ -851,6 +851,51 @@ public function test_adjusts_for_html_integration_points_in_svg() {
851851 );
852852 }
853853
854+ /**
855+ * Ensures that CDATA sections remain available inside SVG HTML integration points.
856+ *
857+ * @ticket 61576
858+ */
859+ public function test_cdata_sections_in_svg_html_integration_points () {
860+ $ processor = WP_HTML_Processor ::create_fragment (
861+ '<svg><foreignObject><![CDATA[foo]]></foreignObject></svg> '
862+ );
863+
864+ $ this ->assertTrue (
865+ $ processor ->next_tag ( 'foreignObject ' ),
866+ 'Failed to find "foreignObject" under test: check test setup. '
867+ );
868+
869+ $ this ->assertSame (
870+ 'svg ' ,
871+ $ processor ->get_namespace (),
872+ 'Found the wrong namespace for the "foreignObject" element. '
873+ );
874+
875+ $ this ->assertTrue (
876+ $ processor ->next_token (),
877+ 'Failed to find expected CDATA section. '
878+ );
879+
880+ $ this ->assertSame (
881+ '#cdata-section ' ,
882+ $ processor ->get_token_name (),
883+ "Should have found a CDATA section but found {$ processor ->get_token_name ()} instead. "
884+ );
885+
886+ $ this ->assertSame (
887+ 'svg ' ,
888+ $ processor ->get_namespace (),
889+ 'Found the wrong namespace for the CDATA section. '
890+ );
891+
892+ $ this ->assertSame (
893+ 'foo ' ,
894+ $ processor ->get_modifiable_text (),
895+ 'Found incorrect CDATA content. '
896+ );
897+ }
898+
854899 /**
855900 * Ensures that the processor correctly adjusts the namespace
856901 * for elements inside MathML integration points.
@@ -911,6 +956,51 @@ public function test_adjusts_for_mathml_integration_points() {
911956 );
912957 }
913958
959+ /**
960+ * Ensures that CDATA sections remain available inside MathML HTML integration points.
961+ *
962+ * @ticket 61576
963+ */
964+ public function test_cdata_sections_in_mathml_html_integration_points () {
965+ $ processor = WP_HTML_Processor ::create_fragment (
966+ '<math><annotation-xml encoding="text/html"><![CDATA[x]]></annotation-xml></math> '
967+ );
968+
969+ $ this ->assertTrue (
970+ $ processor ->next_tag ( 'ANNOTATION-XML ' ),
971+ 'Failed to find "annotation-xml" under test: check test setup. '
972+ );
973+
974+ $ this ->assertSame (
975+ 'math ' ,
976+ $ processor ->get_namespace (),
977+ 'Found the wrong namespace for the "annotation-xml" element. '
978+ );
979+
980+ $ this ->assertTrue (
981+ $ processor ->next_token (),
982+ 'Failed to find expected CDATA section. '
983+ );
984+
985+ $ this ->assertSame (
986+ '#cdata-section ' ,
987+ $ processor ->get_token_name (),
988+ "Should have found a CDATA section but found {$ processor ->get_token_name ()} instead. "
989+ );
990+
991+ $ this ->assertSame (
992+ 'math ' ,
993+ $ processor ->get_namespace (),
994+ 'Found the wrong namespace for the CDATA section. '
995+ );
996+
997+ $ this ->assertSame (
998+ 'x ' ,
999+ $ processor ->get_modifiable_text (),
1000+ 'Found incorrect CDATA content. '
1001+ );
1002+ }
1003+
9141004 /**
9151005 * Ensures that the processor stops correctly on a FORM tag closer token.
9161006 *
0 commit comments