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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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 10:01:29 2024 UTC