xref: /PHP-8.3/ext/pcre/tests/null_bytes.phpt (revision 5bb3e233)
1--TEST--
2Zero byte test
3--FILE--
4<?php
5
6var_dump(preg_match("\0//i", ""));
7var_dump(preg_match("/\0/i", ""));
8var_dump(preg_match("/\0/i", "\0"));
9var_dump(preg_match("//\0i", ""));
10var_dump(preg_match("//i\0", ""));
11var_dump(preg_match("/\\\0/i", ""));
12var_dump(preg_match("/\\\0/i", "\\\0"));
13
14var_dump(preg_match("\0[]i", ""));
15var_dump(preg_match("[\0]i", ""));
16var_dump(preg_match("[\0]i", "\0"));
17var_dump(preg_match("[]\0i", ""));
18var_dump(preg_match("[]i\0", ""));
19var_dump(preg_match("[\\\0]i", ""));
20var_dump(preg_match("[\\\0]i", "\\\0"));
21
22var_dump(preg_match("/abc\0def/", "abc"));
23var_dump(preg_match("/abc\0def/", "abc\0def"));
24var_dump(preg_match("/abc\0def/", "abc\0fed"));
25
26var_dump(preg_match("[abc\0def]", "abc"));
27var_dump(preg_match("[abc\0def]", "abc\0def"));
28var_dump(preg_match("[abc\0def]", "abc\0fed"));
29
30preg_replace("/foo/e\0/i", "echo('Eek');", "");
31
32?>
33--EXPECTF--
34Warning: preg_match(): Delimiter must not be alphanumeric, backslash, or NUL in %snull_bytes.php on line 3
35bool(false)
36int(0)
37int(1)
38
39Warning: preg_match(): NUL is not a valid modifier in %snull_bytes.php on line 6
40bool(false)
41
42Warning: preg_match(): NUL is not a valid modifier in %snull_bytes.php on line 7
43bool(false)
44int(0)
45int(1)
46
47Warning: preg_match(): Delimiter must not be alphanumeric, backslash, or NUL in %snull_bytes.php on line 11
48bool(false)
49int(0)
50int(1)
51
52Warning: preg_match(): NUL is not a valid modifier in %snull_bytes.php on line 14
53bool(false)
54
55Warning: preg_match(): NUL is not a valid modifier in %snull_bytes.php on line 15
56bool(false)
57int(0)
58int(1)
59int(0)
60int(1)
61int(0)
62int(0)
63int(1)
64int(0)
65
66Warning: preg_replace(): NUL is not a valid modifier in %snull_bytes.php on line 27
67