Ticket #24106: 24106.2.patch
| File 24106.2.patch, 2.1 KB (added by , 12 years ago) |
|---|
-
src/wp-includes/formatting.php
3404 3404 } 3405 3405 3406 3406 /** 3407 * Add slashes to a string or array of strings .3407 * Add slashes to a string or array of strings, in recursive manner. 3408 3408 * 3409 3409 * This should be used when preparing data for core API that expects slashed data. 3410 3410 * This should not be used to escape data going directly into an SQL query. … … 3416 3416 */ 3417 3417 function wp_slash( $value ) { 3418 3418 if ( is_array( $value ) ) { 3419 foreach ( $value as $k => $v ) { 3420 if ( is_array( $v ) ) { 3421 $value[$k] = wp_slash( $v ); 3422 } else { 3423 $value[$k] = addslashes( $v ); 3424 } 3425 } 3419 $value = array_map( 'wp_slash', $value ); 3426 3420 } else { 3427 3421 $value = addslashes( $value ); 3428 3422 } -
tests/phpunit/tests/formatting/StripSlashesDeep.php
2 2 3 3 /** 4 4 * @group formatting 5 * @group slashes 5 6 */ 6 7 class Tests_Formatting_StripSlashesDeep extends WP_UnitTestCase { 7 8 /** -
tests/phpunit/tests/formatting/WPSlash.php
1 <?php 2 3 /** 4 * @group formatting 5 * @group slashes 6 */ 7 class Tests_Formatting_WPSlash extends WP_UnitTestCase { 8 9 /** 10 * @ticket 24106 11 */ 12 function test_adds_slashes() { 13 $old = "I can't see, isn't that it?"; 14 $new = "I can\'t see, isn\'t that it?"; 15 $this->assertEquals( $new, wp_slash( $old ) ); 16 $this->assertEquals( "I can\\\\\'t see, isn\\\\\'t that it?", wp_slash( $new ) ); 17 $this->assertEquals( array( 'a' => $new ), wp_slash( array( 'a' => $old ) ) ); // Keyed array 18 $this->assertEquals( array( $new ), wp_slash( array( $old ) ) ); // Non-keyed 19 } 20 21 }