Ticket #30753: 30753.01.patch
File 30753.01.patch, 1.4 KB (added by , 10 years ago) |
---|
-
src/wp-includes/formatting.php
3463 3463 */ 3464 3464 function wp_parse_str( $string, &$array ) { 3465 3465 parse_str( $string, $array ); 3466 if ( get_magic_quotes_gpc() ) 3466 if ( get_magic_quotes_gpc() ) { 3467 3467 $array = stripslashes_deep( $array ); 3468 } 3469 3470 // Cast strings of 'true' and 'false' as proper booleans 3471 foreach( (array) $array as $key => $value ) { 3472 if ( is_string( $value ) && ( 'true' === $value || 'false' === $value ) ) { 3473 $array[$key] = wp_validate_boolean( $value ); 3474 } 3475 } 3476 3468 3477 /** 3469 3478 * Filter the array of variables derived from a parsed string. 3470 3479 * -
new file tests/phpunit/tests/formatting/WPParseStr.php
new file mode 100644
- + 1 <?php 2 3 /** 4 * @group formatting 5 */ 6 class Tests_Formatting_WPParseStr extends WP_UnitTestCase { 7 public function test_querystring_values_as_booleans() { 8 // when a querystring is used as the arg in wp_parse_args(), wp_parse_str() is used 9 $r = wp_parse_args( 'this_should_be_bool_false=false&this_should_be_bool_true=true', array() ); 10 11 $this->assertFalse( $r['this_should_be_bool_false'] ); 12 $this->assertTrue( $r['this_should_be_bool_true'] ); 13 } 14 }