Req #75229 [NEW]: FILTER_VALIDATE_INT should allow 0 prefixes

From: Date: Tue, 19 Sep 2017 14:54:03 +0000
Subject: Req #75229 [NEW]: FILTER_VALIDATE_INT should allow 0 prefixes
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-211252@lists.php.net to get a copy of this message
From: thflori at gmail dot com Operating system: Linux PHP version: 7.1.9 Package: Filter related Bug Type: Feature/Change Request Bug description:FILTER_VALIDATE_INT should allow 0 prefixes Description: ------------ Someone defined octal numbers are prefixed with a 0 but there is no mathematical theory that says a number with one or more 0 in front is not a number. When we now use filter_var to filter user input we have to tell the user that a number with 0 in front is not an integer. Or we use a more generic way like reg exp /^\d+$/ but I thought the filter_var is made for this propose. Currently the problem is that users enter minutes and seconds with zeroes in front. It should indeed not be a float so to filter for integer is correct. Test script: --------------- var_dump(filter_var('03', FILTER_VALIDATE_INT)); var_dump(filter_var('+08', FILTER_VALIDATE_INT)); var_dump(filter_var('-010', FILTER_VALIDATE_INT)); Expected result: ---------------- int(3) int(8) int(-10) Actual result: -------------- false false false -- Edit bug report at https://bugs.php.net/bug.php?id=75229&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75229&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75229&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75229&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75229&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75229&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75229&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75229&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75229&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75229&r=support Expected behavior: https://bugs.php.net/fix.php?id=75229&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75229&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75229&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75229&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75229&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75229&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75229&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75229&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75229&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75229&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75229&r=mysqlcfg

« previous php.bugs (#211252) next »