1
0
mirror of https://github.com/php/php-src.git synced 2026-04-22 23:48:14 +02:00
Files
archived-php-src/ext/standard/tests/strings/bug39621.phpt
T
Nikita Popov ea256a218b 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.
2021-05-29 11:33:13 +02:00

46 lines
867 B
PHP

--TEST--
Bug #39621 (str_replace() is not binary safe on strings with equal length)
--FILE--
<?php
$search = "qxxx\0qqqqqqqq";
$subject = "qxxx\0xxxxxxxx";
$replace = "any text";
$result = str_replace ( $search, $replace, $subject );
var_dump($result);
$search = "QXXX\0qqqqqqqq";
$subject = "qxxx\0xxxxxxxx";
$replace = "any text";
$result = str_ireplace ( $search, $replace, $subject );
var_dump($result);
$search = "qxxx\0xxxxxxxx";
$subject = "qxxx\0xxxxxxxx";
$replace = "any text";
$result = str_replace ( $search, $replace, $subject );
var_dump($result);
$search = "qXxx\0xXxXxXxx";
$subject = "qxXx\0xxxxxxxx";
$replace = "any text";
$result = str_ireplace ( $search, $replace, $subject );
var_dump($result);
echo "Done\n";
?>
--EXPECTF--
string(13) "qxxx%0xxxxxxxx"
string(13) "qxxx%0xxxxxxxx"
string(8) "any text"
string(8) "any text"
Done