#40156 [Opn->Bgs]: FILTER_SANITIZE_NUMBER_FLOAT incorrect when multiple dots in value

From: Date: Wed, 17 Jan 2007 20:11:15 +0000
Subject: #40156 [Opn->Bgs]: FILTER_SANITIZE_NUMBER_FLOAT incorrect when multiple dots in value
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-107692@lists.php.net to get a copy of this message
ID: 40156 Updated by: pajoye@php.net Reported By: pmjones88 at gmail dot com -Status: Open +Status: Bogus Bug Type: Filter related Operating System: Mac OS X PHP Version: 5.2.0 -Assigned To: +Assigned To: pajoye New Comment: Use FILTER_VALIDATE_FLOAT if you like to validate a string and get a float value. Sanitizing filters only clean the string. Previous Comments: ------------------------------------------------------------------------ [2007-01-17 20:01:27] pmjones88 at gmail dot com Description: ------------ When using FILTER_SANITIZE_NUMBER_FLOAT with FILTER_FLAG_ALLOW_FRACTION, it seems to allow any number of decimal points, not just a single decimal point. This results in an invalid value being reported as sanitized. Reproduce code: --------------- <?php $val = 'abc ... 123.45 ,.../'; $san = filter_var($val, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); var_dump($san); ?> Expected result: ---------------- float 123.45 Actual result: -------------- string(12) "...123.45..." ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=40156&edit=1

« previous php.bugs (#107692) next »