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 Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or 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

Add a Patch

Pull Requests

Add a Pull Request

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-2022 The PHP Group
All rights reserved.
Last updated: Mon Jan 24 01:04:10 2022 UTC