Ignore case when checking string 'false' in wp_validate_boolean()
.
Props TobiasBg, kitchin. Fixes #30238. git-svn-id: https://develop.svn.wordpress.org/trunk@30207 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
1219355f2b
commit
2b6df5f8ce
@ -4740,7 +4740,9 @@ function reset_mbstring_encoding() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alternative to filter_var( $var, FILTER_VALIDATE_BOOLEAN ).
|
* Filter/validate a variable as a boolean.
|
||||||
|
*
|
||||||
|
* Alternative to `filter_var( $var, FILTER_VALIDATE_BOOLEAN )`.
|
||||||
*
|
*
|
||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
*
|
*
|
||||||
@ -4752,7 +4754,7 @@ function wp_validate_boolean( $var ) {
|
|||||||
return $var;
|
return $var;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 'false' === $var ) {
|
if ( is_string( $var ) && 'false' === strtolower( $var ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,4 +56,20 @@ class Tests_Functions_WpValidateBoolean extends WP_UnitTestCase {
|
|||||||
// Differs from (bool) conversion.
|
// Differs from (bool) conversion.
|
||||||
$this->assertFalse( wp_validate_boolean( 'false' ) );
|
$this->assertFalse( wp_validate_boolean( 'false' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ticket 30238
|
||||||
|
*/
|
||||||
|
public function test_string_false_uppercase() {
|
||||||
|
// Differs from (bool) conversion.
|
||||||
|
$this->assertFalse( wp_validate_boolean( 'FALSE' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ticket 30238
|
||||||
|
*/
|
||||||
|
public function test_string_false_mixedcase() {
|
||||||
|
// Differs from (bool) conversion.
|
||||||
|
$this->assertFalse( wp_validate_boolean( 'FaLsE' ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user