Bug #63738 [Nab]: unpack string behavior change
Edit report at https://bugs.php.net/bug.php?id=63738&edit=1
ID: 63738
Updated by: aharvey@php.net
Reported by: remi@php.net
Summary: unpack string behavior change
Status: Not a bug
Type: Bug
Package: Strings related
Operating System: GNU/Linux (Fedora 17)
PHP Version: 5.5Git-2012-12-11 (snap)
Block user comment: N
Private report: N
New Comment:
Snap. :)
Previous Comments:
------------------------------------------------------------------------
[2012-12-11 13:57:35] aharvey@php.net
This was intentional â specifically, it was to fix bug #61038. Copy-pasting from the migration
guide (http://php.net/manual/en/migration55.changed-functions.php):
"unpack()'s a format no longer strips trailing null bytes, bringing it into line with
Perl's behaviour."
------------------------------------------------------------------------
[2012-12-11 13:57:30] remi@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
Sorry, haven't read carefully UPGRADING
- pack()/unpack() had the following changes, which bring it more in line
with Perl's behavior:
- Implemented format character "Z": NUL-padded string
- "a" now does not remove trailing NUL characters on unpack() anymore
- "A" will now strip all trailing ASCII whitespace on unpack() (it used to
remove only trailing spaces).
------------------------------------------------------------------------
[2012-12-11 13:51:09] remi@php.net
Description:
------------
Seems a regression between 5.4.9 and 5.5.0-dev
This breaks Archive_Tar
Test script:
---------------
<?php
$a="AB\x00\x00";
var_dump($a);
var_dump(unpack("a4foo", $a));
Expected result:
----------------
With php 5.4.9:
string(4) "AB^@^@"
array(1) {
["foo"]=>
string(2) "AB"
}
Actual result:
--------------
With php 5.5.0-dev:
string(4) "AB^@^@"
array(1) {
["foo"]=>
string(4) "AB^@^@"
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63738&edit=1
Thread (7 messages)