diff --git a/src/wp-includes/kses.php b/src/wp-includes/kses.php index a94542ead0b54..ba3513454d89e 100644 --- a/src/wp-includes/kses.php +++ b/src/wp-includes/kses.php @@ -1824,7 +1824,7 @@ function wp_kses_no_null( $content, $options = null ) { * @return string Fixed string with quoted slashes. */ function wp_kses_stripslashes( $content ) { - return preg_replace( '%\\\\"%', '"', $content ); + return preg_replace( '%(?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( '\\\\"', '\\\\"' ), + ); + } }