Req #41592 [Opn->Csd]: print_r() truncates attribute / property names containing NULL

From: Date: Sun, 02 Nov 2014 00:50:58 +0000
Subject: Req #41592 [Opn->Csd]: print_r() truncates attribute / property names containing NULL
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188412@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=41592&edit=1

 ID:                 41592
 Updated by:         requinix@php.net
 Reported by:        php at digitalbacon dot us
 Summary:            print_r() truncates attribute / property names
                     containing NULL
-Status:             Open
+Status:             Closed
 Type:               Feature/Change Request
-Package:            Feature/Change Request
+Package:            *General Issues
 Operating System:   Windows XP (recent)
 PHP Version:        5.2.3
-Assigned To:        
+Assigned To:        requinix
 Block user comment: N
 Private report:     N

 New Comment:

Fixed in 5.5.
http://3v4l.org/rc678
http://3v4l.org/rEFe1


Previous Comments:
------------------------------------------------------------------------
[2007-06-04 22:59:30] 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 )


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=41592&edit=1


Thread (2 messages)

« previous php.bugs (#188412) next »