Skip to content

Commit 5949d4c

Browse files
committed
Add a basic unit test to prevent regressions.
1 parent dca7d00 commit 5949d4c

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

‎tests/phpunit/tests/kses.php‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff 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
*

0 commit comments

Comments
 (0)