Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 61 additions & 10 deletions tests/phpunit/tests/kses.php
Original file line number Diff line number Diff line change
Expand Up @@ -550,19 +550,70 @@ public function test_hyphenated_tag() {
$this->assertSame( $expect_valid_content, wp_kses( $content, $custom_tags ) );
}

/**
* Data provider.
*/
public static function data_normalize_entities(): array {
return array(
/**
* These examples are from the wp_kses_normalize_entities function description.
*/
'AT&T' => array( 'AT&T', 'AT&T' ),
':' => array( ':', ':' ),
'&#XYZZY;' => array( '&#XYZZY;', '&#XYZZY;' ),

'Named ref &' => array( '♠', '♠' ),
'Named ref &' => array( '♠', '♠' ),
'Named ref ♠' => array( '♠', '♠' ),
'Named ref ¹' => array( '¹', '¹' ),
'Named ref ²' => array( '²', '²' ),
'Named ref ³' => array( '³', '³' ),
'Named ref ¼' => array( '¼', '¼' ),
'Named ref ½' => array( '½', '½' ),
'Named ref ¾' => array( '¾', '¾' ),
'Named ref ∴' => array( '∴', '∴' ),

'Decimal ref 	 ( )' => array( '	', '	' ),
'Decimal ref " (")' => array( '"', '"' ),
'Decimal ref " (")' => array( '"', '"' ),
'Decimal ref & (&)' => array( '&', '&' ),
"Decimal ref ' (')" => array( ''', ''' ),
'Decimal ref 😍 (😍)' => array( '😍', '😍' ),
'Decimal ref 😍 (😍)' => array( '😍', '😍' ),

'Hex ref 	 ( )' => array( '	', '	' ),
'Hex ref " (")' => array( '"', '"' ),
'Hex ref " (")' => array( '"', '"' ),
'Hex ref & (&)' => array( '&', '&' ),
"Hex ref ' (')" => array( ''', ''' ),
'Hex ref 😍 (😍)' => array( '😍', '😍' ),
'Hex ref 😍 (😍)' => array( '😍', '😍' ),

'HEX REF " (")' => array( '"', '"' ),
'HEX REF & (&)' => array( '&', '&' ),
"HEX REF ' (')" => array( ''', ''' ),
'HEX REF 😍 (😍)' => array( '😍', '😍' ),

'Encoded named ref &' => array( '&', '&' ),
'Encoded named ref &' => array( '&', '&' ),
'Encoded named ref &' => array( '&', '&' ),

/*
* The codepoint value here is outside of the valid unicode range whose
* maximum is 0x10FFFF or 1114111.
*/
'Invalid decimal unicode �' => array( '�', '�' ),
'Invalid hex unicode �' => array( '�', '�' ),
);
}

/**
* @ticket 26290
*
* @dataProvider data_normalize_entities
*/
public function test_wp_kses_normalize_entities() {
$this->assertSame( '♠', wp_kses_normalize_entities( '♠' ) );

$this->assertSame( '¹', wp_kses_normalize_entities( '¹' ) );
$this->assertSame( '²', wp_kses_normalize_entities( '²' ) );
$this->assertSame( '³', wp_kses_normalize_entities( '³' ) );
$this->assertSame( '¼', wp_kses_normalize_entities( '¼' ) );
$this->assertSame( '½', wp_kses_normalize_entities( '½' ) );
$this->assertSame( '¾', wp_kses_normalize_entities( '¾' ) );
$this->assertSame( '∴', wp_kses_normalize_entities( '∴' ) );
public function test_wp_kses_normalize_entities( string $input, string $expected ) {
$this->assertSame( $expected, wp_kses_normalize_entities( $input ) );
}

/**
Expand Down
Loading