php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62304 string cast dont work with zero values
Submitted: 2012-06-12 22:08 UTC Modified: 2012-06-12 22:17 UTC
From: zkizzik at gmail dot com Assigned:
Status: Closed Package: Filter related
PHP Version: 5.4.3 OS: All
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: zkizzik at gmail dot com
New email:
PHP Version: OS:

 

 [2012-06-12 22:08 UTC] zkizzik at gmail dot com
Description:
------------
string cast dont work with zero values.

Test script:
---------------
// test.php?price=0
$price = $_GET['price'];
echo htmlspecialchars((string)$price, ENT_QUOTES); // empty
// cast (string) for prevent errors with arrays, for example test.php?price[][][][]=disclosureHere

Expected result:
----------------
0 not empty

Patch in php:
// test.php?price=0
$price = $_GET['price'];
echo (($price === '0') ? '0' : htmlspecialchars((string)$price, ENT_QUOTES));

Actual result:
--------------
empty value :-/

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-12 22:17 UTC] zkizzik at gmail dot com
-Status: Open +Status: Closed
 [2012-06-12 22:17 UTC] zkizzik at gmail dot com
Invalid. x__x
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 23:01:28 2024 UTC