Browse Source
Fixed bug #61038; "Z" and better behavior for unpack()
Fixed bug #61038; "Z" and better behavior for unpack()
Added new "Z" argument to pack/unpack, now allowing "a" to return data without stripping, and "A" strips all trailing white space, while "Z" will strip everything after the first null.pull/60/head
committed by
Gustavo André dos Santos Lopes
5 changed files with 104 additions and 10 deletions
-
4NEWS
-
6UPGRADING
-
63ext/standard/pack.c
-
37ext/standard/tests/strings/bug61038.phpt
-
4ext/standard/tests/strings/unpack_error.phpt
@ -0,0 +1,37 @@ |
|||
--TEST-- |
|||
BugFix #61038 |
|||
--FILE-- |
|||
<?php |
|||
var_dump(unpack("Z4", pack("Z4", "foo"))); |
|||
var_dump(unpack("a4", pack("a4", "foo"))); |
|||
var_dump(unpack("A4", pack("A4", "foo"))); |
|||
var_dump(unpack("a9", pack("a*", "foo\x00bar\x00 "))); |
|||
var_dump(unpack("A9", pack("a*", "foo\x00bar\x00 "))); |
|||
var_dump(unpack("Z9", pack("a*", "foo\x00bar\x00 "))); |
|||
?> |
|||
--EXPECTF-- |
|||
array(1) { |
|||
[1]=> |
|||
string(3) "foo" |
|||
} |
|||
array(1) { |
|||
[1]=> |
|||
string(4) "foo%c" |
|||
} |
|||
array(1) { |
|||
[1]=> |
|||
string(3) "foo" |
|||
} |
|||
array(1) { |
|||
[1]=> |
|||
string(9) "foo%cbar%c " |
|||
} |
|||
array(1) { |
|||
[1]=> |
|||
string(7) "foo%cbar" |
|||
} |
|||
array(1) { |
|||
[1]=> |
|||
string(3) "foo" |
|||
} |
|||
|
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue