Bug #66682 [Opn->Ana]: FILTER_VALIDATE_INT fails on strings starting with zero.

From: Date: Sun, 16 Feb 2014 06:15:48 +0000
Subject: Bug #66682 [Opn->Ana]: FILTER_VALIDATE_INT fails on strings starting with zero.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184318@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66682&edit=1 ID: 66682 Updated by: yohgaki@php.net Reported by: alex dot howansky at gmail dot com Summary: FILTER_VALIDATE_INT fails on strings starting with zero. -Status: Open +Status: Analyzed Type: Bug Package: Filter related Operating System: Linux 2.6 64 PHP Version: 5.5.9 Block user comment: N Private report: N New Comment: This is because php_fileter_int() treats leading 0 as hex/octal numbers. I'm not sure which one int or float should be fixed. Possible fix is https://github.com/yohgaki/php-src/compare/PHP-5.4-bug66682 Previous Comments: ------------------------------------------------------------------------ [2014-02-10 05:40:33] alex dot howansky at gmail dot com Description: ------------ FILTER_VALIDATE_INT fails on '01'. I can understand that opinions might be divided on whether this should return 1 or false -- however, in either case, the behavior of FILTER_VALIDATE_FLOAT should match, and it doesn't. Test script: --------------- var_dump(filter_var('01', FILTER_VALIDATE_INT)); var_dump(filter_var('01', FILTER_VALIDATE_FLOAT)); Expected result: ---------------- int(1) double(1) or: bool(false) bool(false) Actual result: -------------- bool(false) double(1) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=66682&edit=1

« previous php.bugs (#184318) next »