@@ -270,22 +270,6 @@ public function test_style_contents_are_not_escaped() {
270270 );
271271 }
272272
273- /**
274- * XMP contents are parsed using the generic raw text element parsing algorithm.
275- * Their contents should not be escaped with HTML character references on normalization.
276- *
277- * @ticket 65372
278- */
279- public function test_xmp_contents_are_not_escaped () {
280- $ normalized = WP_HTML_Processor::normalize ( "<xmp> < > & \" ' \x00 </xmp> " );
281-
282- $ this ->assertSame (
283- "<xmp> < > & \" ' \u{FFFD} </xmp> " ,
284- $ normalized ,
285- 'Should have preserved text inside an XMP element, except for replacing NULL bytes. '
286- );
287- }
288-
289273 public function test_unexpected_closing_tags_are_removed () {
290274 $ this ->assertSame (
291275 WP_HTML_Processor::normalize ( 'one</div>two</span>three ' ),
@@ -481,9 +465,9 @@ public function test_replaces_null_bytes_appropriately( string $html_with_nulls,
481465 /**
482466 * Data provider.
483467 *
484- * @return array[]
468+ * @return array<string, array{string, string}>
485469 */
486- public static function data_tokens_with_null_bytes () {
470+ public static function data_tokens_with_null_bytes (): array {
487471 return array (
488472 'Tag name ' => array ( "<img \x00id=5> " , "<img \u{FFFD}id=5></img \u{FFFD}id=5> " ),
489473 'Attribute name ' => array ( "<img/ \x00id=5> " , "<img \u{FFFD}id= \"5 \"> " ),
@@ -492,11 +476,45 @@ public static function data_tokens_with_null_bytes() {
492476 'Foreign content text ' => array ( "<svg>one \x00two</svg> " , "<svg>one \u{FFFD}two</svg> " ),
493477 'SCRIPT content ' => array ( "<script>alert( \x00)</script> " , "<script>alert( \u{FFFD})</script> " ),
494478 'STYLE content ' => array ( "<style> \x00 {}</style> " , "<style> \u{FFFD} {}</style> " ),
479+ 'IFRAME content ' => array ( "<iframe>a \x00b</iframe> " , "<iframe>a \u{FFFD}b</iframe> " ),
480+ 'NOEMBED content ' => array ( "<noembed>a \x00b</noembed> " , "<noembed>a \u{FFFD}b</noembed> " ),
481+ 'NOFRAMES content ' => array ( "<noframes>a \x00b</noframes> " , "<noframes>a \u{FFFD}b</noframes> " ),
495482 'XMP content ' => array ( "<xmp>a \x00b</xmp> " , "<xmp>a \u{FFFD}b</xmp> " ),
496483 'Comment text ' => array ( "<!-- \x00 --> " , "<!-- \u{FFFD} --> " ),
497484 );
498485 }
499486
487+ /**
488+ * Ensures that contents of rawtext elements are preserved when serializing.
489+ *
490+ * @ticket 65372
491+ *
492+ * @dataProvider data_rawtext_elements_with_html_syntax_character_contents
493+ *
494+ * @param string $html Normalized HTML containing a rawtext element with contents.
495+ */
496+ public function test_rawtext_element_contents_are_preserved_when_normalizing ( string $ html ): void {
497+ $ this ->assertSame (
498+ $ html ,
499+ WP_HTML_Processor::normalize ( $ html ),
500+ 'Should have preserved the rawtext element contents. '
501+ );
502+ }
503+
504+ /**
505+ * Data provider.
506+ *
507+ * @return array<string, array{string}>
508+ */
509+ public static function data_rawtext_elements_with_html_syntax_character_contents (): array {
510+ return array (
511+ 'IFRAME ' => array ( 'before<iframe> < > & " \' </iframe>after ' ),
512+ 'NOEMBED ' => array ( 'before<noembed> < > & " \' </noembed>after ' ),
513+ 'NOFRAMES ' => array ( 'before<noframes> < > & " \' </noframes>after ' ),
514+ 'XMP ' => array ( 'before<xmp> < > & " \' </xmp>after ' ),
515+ );
516+ }
517+
500518 /**
501519 * @ticket 62396
502520 *
0 commit comments