Skip to content

Commit ea256a2

Browse files
committed
Add %0 format to run-tests.php
This format matches against null bytes, and prevents the test expectation from being interpreted as binary data. bless_tests.php will automatically replace \0 with %0 as well.
1 parent e838de3 commit ea256a2

File tree

120 files changed

+55
-52
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+55
-52
lines changed

Zend/tests/bug60569.phpt

3 Bytes
Binary file not shown.

Zend/tests/bug78363.phpt

1 Byte
Binary file not shown.

Zend/tests/cast_to_array.phpt

5 Bytes
Binary file not shown.

Zend/tests/cast_to_object.phpt

1 Byte
Binary file not shown.

Zend/tests/cast_to_string.phpt

1 Byte
Binary file not shown.

Zend/tests/settype_array.phpt

5 Bytes
Binary file not shown.

Zend/tests/settype_object.phpt

1 Byte
Binary file not shown.

Zend/tests/settype_resource.phpt

1 Byte
Binary file not shown.

Zend/tests/settype_string.phpt

1 Byte
Binary file not shown.

ext/curl/tests/curl_escape.phpt

2 Bytes
Binary file not shown.

ext/exif/tests/exif012.phpt

3 Bytes
Binary file not shown.

ext/exif/tests/exif013.phpt

3 Bytes
Binary file not shown.

ext/exif/tests/exif014.phpt

3 Bytes
Binary file not shown.

ext/exif/tests/exif015.phpt

3 Bytes
Binary file not shown.

ext/exif/tests/exif020.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1618,7 +1618,7 @@ array(34) {
16181618
["Copyright"]=>
16191619
string(12) "Eric Stewart"
16201620
["GPSVersion"]=>
1621-
string(4) " "
1621+
string(4) "%0%0"
16221622
["GPSLatitudeRef"]=>
16231623
string(1) "N"
16241624
["GPSLatitude"]=>
@@ -1642,7 +1642,7 @@ array(34) {
16421642
string(3) "0/1"
16431643
}
16441644
["GPSAltitudeRef"]=>
1645-
string(1) "
1645+
string(1) "%0"
16461646
["GPSAltitude"]=>
16471647
string(5) "295/1"
16481648
["GPSTimeStamp"]=>

ext/exif/tests/exif021.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1618,7 +1618,7 @@ array(34) {
16181618
["Copyright"]=>
16191619
string(12) "Eric Stewart"
16201620
["GPSVersion"]=>
1621-
string(4) " "
1621+
string(4) "%0%0"
16221622
["GPSLatitudeRef"]=>
16231623
string(1) "N"
16241624
["GPSLatitude"]=>
@@ -1642,7 +1642,7 @@ array(34) {
16421642
string(3) "0/1"
16431643
}
16441644
["GPSAltitudeRef"]=>
1645-
string(1) "
1645+
string(1) "%0"
16461646
["GPSAltitude"]=>
16471647
string(5) "295/1"
16481648
["GPSTimeStamp"]=>

ext/exif/tests/exif022.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1642,7 +1642,7 @@ array(45) {
16421642
["ExifImageLength"]=>
16431643
int(1)
16441644
["GPSVersion"]=>
1645-
string(4) " "
1645+
string(4) "%0%0"
16461646
["GPSLatitudeRef"]=>
16471647
string(1) "N"
16481648
["GPSLatitude"]=>
@@ -1666,7 +1666,7 @@ array(45) {
16661666
string(3) "0/1"
16671667
}
16681668
["GPSAltitudeRef"]=>
1669-
string(1) "
1669+
string(1) "%0"
16701670
["GPSAltitude"]=>
16711671
string(5) "295/1"
16721672
["GPSTimeStamp"]=>

ext/exif/tests/exif023.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1642,7 +1642,7 @@ array(45) {
16421642
["ExifImageLength"]=>
16431643
int(1)
16441644
["GPSVersion"]=>
1645-
string(4) " "
1645+
string(4) "%0%0"
16461646
["GPSLatitudeRef"]=>
16471647
string(1) "N"
16481648
["GPSLatitude"]=>
@@ -1666,7 +1666,7 @@ array(45) {
16661666
string(3) "0/1"
16671667
}
16681668
["GPSAltitudeRef"]=>
1669-
string(1) "
1669+
string(1) "%0"
16701670
["GPSAltitude"]=>
16711671
string(5) "295/1"
16721672
["GPSTimeStamp"]=>

ext/ftp/tests/ftp_fget_basic.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ $position = ftell($fp);
2424
//test binary data transfer
2525
var_dump(ftp_fget($ftp, $fp, 'binary data.bin', FTP_BINARY));
2626
fseek($fp, $position);
27-
var_dump(urlencode(fgets($fp)));
27+
echo json_encode(fgets($fp)), "\n";
2828

2929
//test non-existent file request
3030
ftp_fget($ftp, $fp ,'a warning.txt', FTP_ASCII);
@@ -37,6 +37,6 @@ bool(true)
3737
bool(true)
3838
For sale: baby shoes, never worn.
3939
bool(true)
40-
string(21) "BINARYFoo%00Bar%0D%0A"
40+
"BINARYFoo\u0000Bar\r\n"
4141

4242
Warning: ftp_fget(): a warning: No such file or directory in %sftp_fget_basic.php on line %d

ext/ftp/tests/ftp_get_basic.phpt

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ unlink($tmpfname);
2323
//test binary data transfer
2424
$tmpfname = tempnam(__DIR__, "ftp_test");
2525
var_dump(ftp_get($ftp, $tmpfname, 'binary data.bin', FTP_BINARY));
26-
var_dump(urlencode(file_get_contents($tmpfname)));
26+
echo json_encode(file_get_contents($tmpfname)), "\n";
2727
unlink($tmpfname);
2828

2929
//test non-existent file request
@@ -34,6 +34,6 @@ bool(true)
3434
bool(true)
3535
For sale: baby shoes, never worn.
3636
bool(true)
37-
string(21) "BINARYFoo%00Bar%0D%0A"
37+
"BINARYFoo\u0000Bar\r\n"
3838

3939
Warning: ftp_get(): a warning: No such file or directory in %sftp_get_basic.php on line %d

ext/oci8/tests/lob_001.phpt

20 Bytes
Binary file not shown.

ext/oci8/tests/lob_003.phpt

10 Bytes
Binary file not shown.

ext/oci8/tests/lob_006.phpt

10 Bytes
Binary file not shown.

ext/oci8/tests/lob_019.phpt

10 Bytes
Binary file not shown.

ext/oci8/tests/lob_020.phpt

10 Bytes
Binary file not shown.
17 Bytes
Binary file not shown.

ext/pdo_mysql/tests/bug_39483.phpt

3 Bytes
Binary file not shown.

ext/spl/tests/array_018.phpt

2 Bytes
Binary file not shown.

ext/spl/tests/iterator_049b.phpt

18 Bytes
Binary file not shown.
7 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 Bytes
Binary file not shown.
3 Bytes
Binary file not shown.
Binary file not shown.
9 Bytes
Binary file not shown.
9 Bytes
Binary file not shown.
2 Bytes
Binary file not shown.
9 Bytes
Binary file not shown.
9 Bytes
Binary file not shown.
Binary file not shown.
5 Bytes
Binary file not shown.
5 Bytes
Binary file not shown.
2 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.

ext/standard/tests/file/basename.phpt

5 Bytes
Binary file not shown.

ext/standard/tests/file/bug26003.phpt

2 Bytes
Binary file not shown.
3 Bytes
Binary file not shown.
11 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

ext/standard/tests/general_functions/print_r.phpt

+10-10
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ closedir($dir_handle);
271271

272272
echo "Done\n";
273273
?>
274-
--EXPECT--
274+
--EXPECTF--
275275
*** Testing print_r() on integer variables ***
276276

277277
-- Iteration 1 --
@@ -565,9 +565,9 @@ Array
565565
0
566566
0
567567
-- Iteration 6 --
568-
569-
570-
568+
%0
569+
%0
570+
%0
571571
-- Iteration 7 --
572572
\0
573573
\0
@@ -589,13 +589,13 @@ PHP
589589
PHP
590590
PHP
591591
-- Iteration 12 --
592-
abcd n1234 05678
593-
abcd n1234 05678
594-
abcd n1234 05678
592+
abcd%0n1234%005678%000efgh\xijkl
593+
abcd%0n1234%005678%000efgh\xijkl
594+
abcd%0n1234%005678%000efgh\xijkl
595595
-- Iteration 13 --
596-
abcd efgh ijkl mnop 0qrst uvwx 0yz
597-
abcd efgh ijkl mnop 0qrst uvwx 0yz
598-
abcd efgh ijkl mnop 0qrst uvwx 0yz
596+
abcd%0efgh%0ijkl%0mnop%00qrst%0uvwx%00yz
597+
abcd%0efgh%0ijkl%0mnop%00qrst%0uvwx%00yz
598+
abcd%0efgh%0ijkl%0mnop%00qrst%0uvwx%00yz
599599
-- Iteration 14 --
600600
1234
601601
5678

ext/standard/tests/general_functions/print_r_64bit.phpt

+10-10
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ closedir($dir_handle);
275275

276276
echo "Done\n";
277277
?>
278-
--EXPECT--
278+
--EXPECTF--
279279
*** Testing print_r() on integer variables ***
280280

281281
-- Iteration 1 --
@@ -569,9 +569,9 @@ Array
569569
0
570570
0
571571
-- Iteration 6 --
572-
573-
574-
572+
%0
573+
%0
574+
%0
575575
-- Iteration 7 --
576576
\0
577577
\0
@@ -593,13 +593,13 @@ PHP
593593
PHP
594594
PHP
595595
-- Iteration 12 --
596-
abcd n1234 05678
597-
abcd n1234 05678
598-
abcd n1234 05678
596+
abcd%0n1234%005678%000efgh\xijkl
597+
abcd%0n1234%005678%000efgh\xijkl
598+
abcd%0n1234%005678%000efgh\xijkl
599599
-- Iteration 13 --
600-
abcd efgh ijkl mnop 0qrst uvwx 0yz
601-
abcd efgh ijkl mnop 0qrst uvwx 0yz
602-
abcd efgh ijkl mnop 0qrst uvwx 0yz
600+
abcd%0efgh%0ijkl%0mnop%00qrst%0uvwx%00yz
601+
abcd%0efgh%0ijkl%0mnop%00qrst%0uvwx%00yz
602+
abcd%0efgh%0ijkl%0mnop%00qrst%0uvwx%00yz
603603
-- Iteration 14 --
604604
1234
605605
5678

ext/standard/tests/general_functions/var_dump.phpt

+6-6
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ string(1) " "
427427
-- Iteration 5 --
428428
string(1) "0"
429429
-- Iteration 6 --
430-
string(1) "
430+
string(1) "%0"
431431
-- Iteration 7 --
432432
string(2) "\0"
433433
-- Iteration 8 --
@@ -439,9 +439,9 @@ string(3) "PHP"
439439
-- Iteration 11 --
440440
string(3) "PHP"
441441
-- Iteration 12 --
442-
string(29) "abcd n1234 05678
442+
string(29) "abcd%0n1234%005678%000efgh\xijkl"
443443
-- Iteration 13 --
444-
string(34) "abcd efgh ijkl mnop 0qrst uvwx 0yz"
444+
string(34) "abcd%0efgh%0ijkl%0mnop%00qrst%0uvwx%00yz"
445445
-- Iteration 14 --
446446
string(22) "1234
447447
5678
@@ -1081,7 +1081,7 @@ array(14) {
10811081
[4]=>
10821082
string(1) "0"
10831083
[5]=>
1084-
string(1) "
1084+
string(1) "%0"
10851085
[6]=>
10861086
string(2) "\0"
10871087
[7]=>
@@ -1093,9 +1093,9 @@ array(14) {
10931093
[10]=>
10941094
string(3) "PHP"
10951095
[11]=>
1096-
string(29) "abcd n1234 05678
1096+
string(29) "abcd%0n1234%005678%000efgh\xijkl"
10971097
[12]=>
1098-
string(34) "abcd efgh ijkl mnop 0qrst uvwx 0yz"
1098+
string(34) "abcd%0efgh%0ijkl%0mnop%00qrst%0uvwx%00yz"
10991099
[13]=>
11001100
string(22) "1234
11011101
5678

ext/standard/tests/general_functions/var_dump_64bit.phpt

+7-7
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ closedir($dir_handle);
274274

275275
echo "Done\n";
276276
?>
277-
--EXPECT--
277+
--EXPECTF--
278278
*** Testing var_dump() on integer variables ***
279279
-- Iteration 1 --
280280
int(0)
@@ -427,7 +427,7 @@ string(1) " "
427427
-- Iteration 5 --
428428
string(1) "0"
429429
-- Iteration 6 --
430-
string(1) "
430+
string(1) "%0"
431431
-- Iteration 7 --
432432
string(2) "\0"
433433
-- Iteration 8 --
@@ -439,9 +439,9 @@ string(3) "PHP"
439439
-- Iteration 11 --
440440
string(3) "PHP"
441441
-- Iteration 12 --
442-
string(29) "abcd n1234 05678
442+
string(29) "abcd%0n1234%005678%000efgh\xijkl"
443443
-- Iteration 13 --
444-
string(34) "abcd efgh ijkl mnop 0qrst uvwx 0yz"
444+
string(34) "abcd%0efgh%0ijkl%0mnop%00qrst%0uvwx%00yz"
445445
-- Iteration 14 --
446446
string(22) "1234
447447
5678
@@ -1081,7 +1081,7 @@ array(14) {
10811081
[4]=>
10821082
string(1) "0"
10831083
[5]=>
1084-
string(1) "
1084+
string(1) "%0"
10851085
[6]=>
10861086
string(2) "\0"
10871087
[7]=>
@@ -1093,9 +1093,9 @@ array(14) {
10931093
[10]=>
10941094
string(3) "PHP"
10951095
[11]=>
1096-
string(29) "abcd n1234 05678
1096+
string(29) "abcd%0n1234%005678%000efgh\xijkl"
10971097
[12]=>
1098-
string(34) "abcd efgh ijkl mnop 0qrst uvwx 0yz"
1098+
string(34) "abcd%0efgh%0ijkl%0mnop%00qrst%0uvwx%00yz"
10991099
[13]=>
11001100
string(22) "1234
11011101
5678

ext/standard/tests/math/bug62112.phpt

2 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10 Bytes
Binary file not shown.
2 Bytes
Binary file not shown.
3 Bytes
Binary file not shown.
5 Bytes
Binary file not shown.
3 Bytes
Binary file not shown.
3 Bytes
Binary file not shown.
4 Bytes
Binary file not shown.
3 Bytes
Binary file not shown.
7 Bytes
Binary file not shown.
26 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
32 Bytes
Binary file not shown.
38 Bytes
Binary file not shown.
4 Bytes
Binary file not shown.
3 Bytes
Binary file not shown.
1 Byte
Binary file not shown.
4 Bytes
Binary file not shown.

ext/standard/tests/strings/printf.phpt

+3-3
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,8 @@ Array
486486
[4] => 99
487487
)
488488

489-
490-
489+
%0
490+
%0
491491
C
492492
½
493493
c
@@ -595,7 +595,7 @@ Array
595595
(
596596
[0] => %5s
597597
[1] => %-5s
598-
[2] => %05s
598+
[2] => %r%%r05s
599599
[3] => %'#5s
600600
)
601601

ext/standard/tests/strings/printf_64bit.phpt

+3-3
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,8 @@ Array
486486
[4] => 99
487487
)
488488

489-
490-
489+
%0
490+
%0
491491
C
492492
½
493493
c
@@ -595,7 +595,7 @@ Array
595595
(
596596
[0] => %5s
597597
[1] => %-5s
598-
[2] => %05s
598+
[2] => %r%%r05s
599599
[3] => %'#5s
600600
)
601601

Binary file not shown.

ext/standard/tests/strings/rtrim.phpt

3 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
11 Bytes
Binary file not shown.
15 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 Bytes
Binary file not shown.
5 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
12 Bytes
Binary file not shown.
44 Bytes
Binary file not shown.
2 Bytes
Binary file not shown.
2 Bytes
Binary file not shown.
Binary file not shown.
2 Bytes
Binary file not shown.
3 Bytes
Binary file not shown.

ext/standard/tests/strings/trim1.phpt

3 Bytes
Binary file not shown.
3 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

run-tests.php

+1
Original file line numberDiff line numberDiff line change
@@ -2627,6 +2627,7 @@ function run_test(string $php, $file, array $env): string
26272627
$wanted_re = str_replace('%x', '[0-9a-fA-F]+', $wanted_re);
26282628
$wanted_re = str_replace('%f', '[+-]?\.?\d+\.?\d*(?:[Ee][+-]?\d+)?', $wanted_re);
26292629
$wanted_re = str_replace('%c', '.', $wanted_re);
2630+
$wanted_re = str_replace('%0', '\x00', $wanted_re);
26302631
// %f allows two points "-.0.0" but that is the best *simple* expression
26312632
}
26322633

scripts/dev/bless_tests.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ function normalizeOutput(string $out): string {
7272
'Resource ID#%d used as offset, casting to integer (%d)',
7373
$out);
7474
$out = preg_replace('/string\(\d+\) "([^"]*%d)/', 'string(%d) "$1', $out);
75+
$out = str_replace("\0", '%0', $out);
7576
return $out;
7677
}
7778

@@ -86,6 +87,7 @@ function formatToRegex(string $format): string {
8687
$result = str_replace('%x', '[0-9a-fA-F]+', $result);
8788
$result = str_replace('%f', '[+-]?\.?\d+\.?\d*(?:[Ee][+-]?\d+)?', $result);
8889
$result = str_replace('%c', '.', $result);
90+
$result = str_replace('%0', '\0', $result);
8991
return "/^$result$/s";
9092
}
9193

@@ -113,7 +115,7 @@ function generateMinimallyDifferingOutput(string $out, string $oldExpect) {
113115

114116
function insertOutput(string $phpt, string $out): string {
115117
return preg_replace_callback('/--EXPECTF?--.*?(--CLEAN--|$)/sD', function($matches) use($out) {
116-
$hasWildcard = preg_match('/%[resSaAwidxfc]/', $out);
118+
$hasWildcard = preg_match('/%[resSaAwidxfc0]/', $out);
117119
$F = $hasWildcard ? 'F' : '';
118120
return "--EXPECT$F--\n" . $out . "\n" . $matches[1];
119121
}, $phpt);

0 commit comments

Comments
 (0)