Bug #51344 [NEW]: FILTER_NULL_ON_FAILURE flag automatically set in filter_input() functions.
| From: | pravila at alumni dot calpoly dot edu | Date: | Sun, 21 Mar 2010 17:02:46 +0000 |
| Subject: | Bug #51344 [NEW]: FILTER_NULL_ON_FAILURE flag automatically set in filter_input() functions. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-148805@lists.php.net to get a copy of this message | ||
From:
Operating system: Linux
PHP version: 5.2.13
Package: Filter related
Bug Type: Bug
Bug description:FILTER_NULL_ON_FAILURE flag automatically set in filter_input() functions.
Description:
------------
* This is different than bug http://bugs.php.net/bug.php?id=41305 *
The filter_var() vs. the filter_input() behave differently when using the
FILTER_VALIDATE_BOOLEAN filter when the variable/input doesn't exist.
More specifically, it seems as if the FILTER_NULL_ON_FAILURE flag is set
automatically in the filter_input() function.
(Note: same behavior for filter_var_array() vs. filter_input_array()).
From PHPINFO():
filter.default = unsafe_raw
filter.default_flags = no value
Revision: 1.52.2.39.2.16
Test script:
---------------
<?php
// example.com/script.php?arg1=yes&arg3=no
// filtering by variable
$var1 = filter_var($_GET["arg1"], FILTER_VALIDATE_BOOLEAN);
$var2 = filter_var($_GET["arg2"], FILTER_VALIDATE_BOOLEAN);
$var3 = filter_var($_GET["arg3"], FILTER_VALIDATE_BOOLEAN);
// filtering by input
$input1 = filter_input(INPUT_GET, "arg1", FILTER_VALIDATE_BOOLEAN);
$input2 = filter_input(INPUT_GET, "arg2", FILTER_VALIDATE_BOOLEAN);
$input3 = filter_input(INPUT_GET, "arg3", FILTER_VALIDATE_BOOLEAN);
// as expected...
var_dump($var1); // bool(true)
var_dump($var2); // bool(false)
var_dump($var3); // bool(false)
// NULL is not an expected return unless the FILTER_NULL_ON_FAILURE flag is
set...
var_dump($input1); // bool(true)
var_dump($input2); // NULL
var_dump($input3); // bool(false)
?>
Expected result:
----------------
As per the documentation, we expect the output of the code above to be:
bool(true)
bool(false)
bool(false)
bool(true)
bool(false)
bool(false)
Actual result:
--------------
Even though the FILTER_NULL_ON_FAILURE flag is NOT set, we DO get a NULL
value in
the output:
bool(true)
bool(false)
bool(false)
bool(true)
NULL
bool(false)
--
Edit bug report at http://bugs.php.net/bug.php?id=51344&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51344&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51344&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51344&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=51344&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51344&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=51344&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=51344&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=51344&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=51344&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=51344&r=support
Expected behavior: http://bugs.php.net/fix.php?id=51344&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=51344&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=51344&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=51344&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51344&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=51344&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=51344&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=51344&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=51344&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=51344&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=51344&r=mysqlcfg