File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1912,6 +1912,35 @@ public function filter_wp_kses_object_added_in_html_filter( $tags, $context ) {
19121912 return $ tags ;
19131913 }
19141914
1915+ /**
1916+ * Ensures that `wp_kses()` preserves various kinds of HTML comments, both valid and invalid.
1917+ *
1918+ * @ticket 61009
1919+ *
1920+ * @param string $html_comment HTML containing a comment; must not be a valid comment
1921+ * but must be syntax which a browser interprets as a comment.
1922+ * @param string $expected_output How `wp_kses()` ought to transform the comment.
1923+ */
1924+ public function wp_kses_preserves_html_comments ( $ html_comment , $ expected_output ) {
1925+ $ this ->assertSame (
1926+ $ expected_output ,
1927+ wp_kses ( $ html_comment , array () ),
1928+ 'Failed to properly preserve HTML comment. '
1929+ );
1930+ }
1931+
1932+ /**
1933+ * Data provider.
1934+ *
1935+ * @return array[].
1936+ */
1937+ public static function data_html_containing_various_kinds_of_html_comments () {
1938+ return array (
1939+ 'Normative HTML comment ' => array ( 'before<!-- this is a comment -->after ' , 'before<!-- this is a comment -->after ' ),
1940+ 'Closing tag with invalid tag name ' => array ( 'before<//not a tag>after ' , 'before<//not a tag>after ' ),
1941+ );
1942+ }
1943+
19151944 /**
19161945 * Test that attributes with a list of allowed values are filtered correctly.
19171946 *
You can’t perform that action at this time.
0 commit comments