Skip to content
Draft
Changes from 1 commit
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
Next Next commit
Add kses stripslashes tests
  • Loading branch information
sirreal committed Aug 21, 2025
commit f7421827b016cad87b0ed1e50227f16668c30a29
32 changes: 32 additions & 0 deletions tests/phpunit/tests/kses.php
Original file line number Diff line number Diff line change
Expand Up @@ -2377,4 +2377,36 @@ public function data_allowed_attributes_in_descriptions() {
),
);
}

/**
* @dataProvider data_kses_stripslashes
*
* @ticket TBD
*
* @param string $input Input string.
* @param array $expected Expected result after applying `wp_kses_stripslashes()`.
*/
public function test_kses_stripslashes( $input, $expected ) {
$this->assertSame( $expected, wp_kses_stripslashes( $input ) );
}

/**
* Data provider for test_specific_attributes_preserved_in_context.
*
* @return array
*/
public static function data_kses_stripslashes() {
return array(
'Text untouched' => array( 'Text is untouched', 'Text is untouched' ),
'Multibyte untouched' => array( 'áêiõü🏴󠁧󠁢󠁥󠁮󠁧󠁿', 'áêiõü🏴󠁧󠁢󠁥󠁮󠁧󠁿' ),
'HTML characters untouched' => array( '<>&\'"', '<>&\'"' ),
'" on its own untouched' => array( '"', '"' ),
'\\" to "' => array( '\\"', '"' ),
'\\\' ignored' => array( '\\\'', '\\\'' ),
'\\ ignored' => array( '\\', '\\' ),

'unescaped \\ before " is stripped' => array( '\\\\\\"', '\\\\"' ),
'escaped \\ before " is not stripped' => array( '\\\\"', '\\\\"' ),
);
}
}