php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #41592 print_r() truncates attribute / property names containing NULL
Submitted: 2007-06-04 22:59 UTC Modified: 2014-11-02 00:50 UTC
From: php at digitalbacon dot us Assigned: requinix (profile)
Status: Closed Package: *General Issues
PHP Version: 5.2.3 OS: Windows XP (recent)
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: php at digitalbacon dot us
New email:
PHP Version: OS:

 

 [2007-06-04 22:59 UTC] php at digitalbacon dot us
Description:
------------
If you have a property name containing a NULL character, some PHP routines like print_r() will truncate the name, most likely due to C-string processing limitations.

I know PHP syntax doesn't permit NULL characters within attribute names, however, it's easily done when the name is contained in a variable. The only limitation seems to be that an attribute cannot start with NULL. Since it's "allowed," then PHP should fully support its effects.

Reproduce code:
---------------
<?php
$c = new stdClass;
$a = "HIDDEN\000-TEXT";
$c->$a = 'foo';
print_r($c);
?>

Expected result:
----------------
stdClass Object ( ["HIDDEN\000-TEXT"] => foo )

Actual result:
--------------
stdClass Object ( [HIDDEN] => foo )

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-11-02 00:50 UTC] requinix@php.net
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: requinix
 [2014-11-02 00:50 UTC] requinix@php.net
Fixed in 5.5.
http://3v4l.org/rc678
http://3v4l.org/rEFe1
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 21:01:33 2024 UTC