diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 908bf2cac22..563dce2157c 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -649,7 +649,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, bo if (key != regex) { zend_string_release_ex(key, 0); } - php_error_docref(NULL, E_WARNING, "Delimiter must not be alphanumeric, backslash, or NUL"); + php_error_docref(NULL, E_WARNING, "Delimiter must not be alphanumeric, backslash, or NUL byte"); pcre_handle_exec_error(PCRE2_ERROR_INTERNAL); return NULL; } @@ -745,7 +745,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, bo if (pp[-1]) { php_error_docref(NULL, E_WARNING, "Unknown modifier '%c'", pp[-1]); } else { - php_error_docref(NULL, E_WARNING, "NUL is not a valid modifier"); + php_error_docref(NULL, E_WARNING, "NUL byte is not a valid modifier"); } pcre_handle_exec_error(PCRE2_ERROR_INTERNAL); efree(pattern); diff --git a/ext/pcre/tests/bug73392.phpt b/ext/pcre/tests/bug73392.phpt index a1cb3ac8480..28cf6ea1af6 100644 --- a/ext/pcre/tests/bug73392.phpt +++ b/ext/pcre/tests/bug73392.phpt @@ -15,11 +15,21 @@ class Foo { function b() { return "b"; } -var_dump(preg_replace_callback_array( - array( - "/a/" => 'b', "/b/" => function () { return "c"; }, "/c/" => new Rep, "reporting" => array("Foo", "rep"), "a1" => array("Foo", "rep"), - ), 'a')); +var_dump( + preg_replace_callback_array( + [ + "/a/" => 'b', + "/b/" => function () { + return 'c'; + }, + "/c/" => new Rep(), + "reporting" => ["Foo", "rep"], + "a1" => ["Foo", "rep"], + ], + 'a' + ) +); ?> --EXPECTF-- -Warning: preg_replace_callback_array(): Delimiter must not be alphanumeric, backslash, or NUL in %sbug73392.php on line %d +Warning: preg_replace_callback_array(): Delimiter must not be alphanumeric, backslash, or NUL byte in %sbug73392.php on line %d NULL diff --git a/ext/pcre/tests/delimiters.phpt b/ext/pcre/tests/delimiters.phpt index beeebc8cbc2..75558c6ca92 100644 --- a/ext/pcre/tests/delimiters.phpt +++ b/ext/pcre/tests/delimiters.phpt @@ -23,7 +23,7 @@ Warning: preg_match(): Empty regular expression in %sdelimiters.php on line 4 bool(false) int(1) -Warning: preg_match(): Delimiter must not be alphanumeric, backslash, or NUL in %sdelimiters.php on line 6 +Warning: preg_match(): Delimiter must not be alphanumeric, backslash, or NUL byte in %sdelimiters.php on line 6 bool(false) int(1) @@ -37,5 +37,5 @@ bool(false) Warning: preg_match(): No ending matching delimiter '}' found in %sdelimiters.php on line 11 bool(false) -Warning: preg_match(): Delimiter must not be alphanumeric, backslash, or NUL in %sdelimiters.php on line 12 +Warning: preg_match(): Delimiter must not be alphanumeric, backslash, or NUL byte in %sdelimiters.php on line 12 bool(false) diff --git a/ext/pcre/tests/null_bytes.phpt b/ext/pcre/tests/null_bytes.phpt index b5d4031c33f..b514fc86bce 100644 --- a/ext/pcre/tests/null_bytes.phpt +++ b/ext/pcre/tests/null_bytes.phpt @@ -29,28 +29,28 @@ var_dump(preg_match("[abc\0def]", "abc\0fed")); ?> --EXPECTF-- -Warning: preg_match(): Delimiter must not be alphanumeric, backslash, or NUL in %snull_bytes.php on line 3 +Warning: preg_match(): Delimiter must not be alphanumeric, backslash, or NUL byte in %snull_bytes.php on line 3 bool(false) int(0) int(1) -Warning: preg_match(): NUL is not a valid modifier in %snull_bytes.php on line 6 +Warning: preg_match(): NUL byte is not a valid modifier in %snull_bytes.php on line 6 bool(false) -Warning: preg_match(): NUL is not a valid modifier in %snull_bytes.php on line 7 +Warning: preg_match(): NUL byte is not a valid modifier in %snull_bytes.php on line 7 bool(false) int(0) int(1) -Warning: preg_match(): Delimiter must not be alphanumeric, backslash, or NUL in %snull_bytes.php on line 11 +Warning: preg_match(): Delimiter must not be alphanumeric, backslash, or NUL byte in %snull_bytes.php on line 11 bool(false) int(0) int(1) -Warning: preg_match(): NUL is not a valid modifier in %snull_bytes.php on line 14 +Warning: preg_match(): NUL byte is not a valid modifier in %snull_bytes.php on line 14 bool(false) -Warning: preg_match(): NUL is not a valid modifier in %snull_bytes.php on line 15 +Warning: preg_match(): NUL byte is not a valid modifier in %snull_bytes.php on line 15 bool(false) int(0) int(1) diff --git a/ext/pcre/tests/preg_grep_error1.phpt b/ext/pcre/tests/preg_grep_error1.phpt index 00425364507..ae80ecc3506 100644 --- a/ext/pcre/tests/preg_grep_error1.phpt +++ b/ext/pcre/tests/preg_grep_error1.phpt @@ -3,21 +3,25 @@ Test preg_grep() function : error conditions - bad regular expressions --FILE-- getMessage(), "\n"; } -echo "Done" ?> --EXPECTF-- -*** Testing preg_grep() : error conditions *** -Arg value is abcdef - -Warning: preg_grep(): Delimiter must not be alphanumeric, backslash, or NUL in %spreg_grep_error1.php on line %d +Warning: preg_grep(): Delimiter must not be alphanumeric, backslash, or NUL byte in %spreg_grep_error1.php on line %d bool(false) -Arg value is /[a-zA-Z] - Warning: preg_grep(): No ending delimiter '/' found in %spreg_grep_error1.php on line %d bool(false) -Arg value is [a-zA-Z]/ - Warning: preg_grep(): Unknown modifier '/' in %spreg_grep_error1.php on line %d bool(false) -Arg value is /[a-zA-Z]/F - Warning: preg_grep(): Unknown modifier 'F' in %spreg_grep_error1.php on line %d bool(false) - -Arg value is Array preg_grep(): Argument #1 ($pattern) must be of type string, array given - -Arg value is /[a-zA-Z]/ array(2) { [1]=> string(3) "abc" @@ -66,4 +56,3 @@ array(2) { string(4) "test" } preg_grep(): Argument #1 ($pattern) must be of type string, stdClass given -Done diff --git a/ext/pcre/tests/preg_match_all_error1.phpt b/ext/pcre/tests/preg_match_all_error1.phpt index 01e0615ad38..92d1a6aff66 100644 --- a/ext/pcre/tests/preg_match_all_error1.phpt +++ b/ext/pcre/tests/preg_match_all_error1.phpt @@ -3,21 +3,25 @@ Test preg_match_all() function : error conditions - bad regular expressions --FILE-- --EXPECTF-- -*** Testing preg_match_all() : error conditions *** -Arg value is abcdef - -Warning: preg_match_all(): Delimiter must not be alphanumeric, backslash, or NUL in %spreg_match_all_error1.php on line %d +Warning: preg_match_all(): Delimiter must not be alphanumeric, backslash, or NUL byte in %spreg_match_all_error1.php on line %d bool(false) NULL -Arg value is /[a-zA-Z] - Warning: preg_match_all(): No ending delimiter '/' found in %spreg_match_all_error1.php on line %d bool(false) NULL -Arg value is [a-zA-Z]/ - Warning: preg_match_all(): Unknown modifier '/' in %spreg_match_all_error1.php on line %d bool(false) NULL -Arg value is /[a-zA-Z]/F - Warning: preg_match_all(): Unknown modifier 'F' in %spreg_match_all_error1.php on line %d bool(false) NULL - -Arg value is Array preg_match_all(): Argument #1 ($pattern) must be of type string, array given NULL - -Arg value is /[a-zA-Z]/ int(4) array(1) { [0]=> diff --git a/ext/pcre/tests/preg_match_all_error2.phpt b/ext/pcre/tests/preg_match_all_error2.phpt deleted file mode 100644 index bffd84552e8..00000000000 --- a/ext/pcre/tests/preg_match_all_error2.phpt +++ /dev/null @@ -1,47 +0,0 @@ ---TEST-- -Test preg_match_all() function : error conditions - wrong arg types ---FILE-- -getMessage(), "\n"; - } - var_dump($matches); -} -echo "Done"; -?> ---EXPECT-- -*** Testing preg_match_all() : error conditions *** - -Arg value is: Array -preg_match_all(): Argument #2 ($subject) must be of type string, array given -NULL - -Arg value is: test -int(4) -array(1) { - [0]=> - array(4) { - [0]=> - string(1) "t" - [1]=> - string(1) "e" - [2]=> - string(1) "s" - [3]=> - string(1) "t" - } -} -Done diff --git a/ext/pcre/tests/preg_match_error1.phpt b/ext/pcre/tests/preg_match_error1.phpt index e97ddb92675..870cc498792 100644 --- a/ext/pcre/tests/preg_match_error1.phpt +++ b/ext/pcre/tests/preg_match_error1.phpt @@ -4,18 +4,22 @@ Test preg_match() function : error conditions - bad regular expressions getMessage(), "\n"; } + ?> --EXPECTF-- -*** Testing preg_match() : error conditions *** -Arg value is abcdef - -Warning: preg_match(): Delimiter must not be alphanumeric, backslash, or NUL in %spreg_match_error1.php on line %d +Warning: preg_match(): Delimiter must not be alphanumeric, backslash, or NUL byte in %spreg_match_error1.php on line %d bool(false) -Arg value is /[a-zA-Z] - Warning: preg_match(): No ending delimiter '/' found in %spreg_match_error1.php on line %d bool(false) -Arg value is [a-zA-Z]/ - Warning: preg_match(): Unknown modifier '/' in %spreg_match_error1.php on line %d bool(false) -Arg value is /[a-zA-Z]/F - Warning: preg_match(): Unknown modifier 'F' in %spreg_match_error1.php on line %d bool(false) - -Arg value is Array preg_match(): Argument #1 ($pattern) must be of type string, array given - -Arg value is /[a-zA-Z]/ int(1) preg_match(): Argument #1 ($pattern) must be of type string, stdClass given diff --git a/ext/pcre/tests/preg_match_error2.phpt b/ext/pcre/tests/preg_match_error2.phpt deleted file mode 100644 index 48aafd3713b..00000000000 --- a/ext/pcre/tests/preg_match_error2.phpt +++ /dev/null @@ -1,37 +0,0 @@ ---TEST-- -Test preg_match() function : error conditions - wrong arg types ---FILE-- -getMessage(), "\n"; - } -} -$value = new stdclass(); //Object -try { - var_dump(preg_match($regex, $value)); -} catch (TypeError $e) { - echo $e->getMessage(), "\n"; -} -echo "Done"; -?> ---EXPECT-- -*** Testing preg_match() : error conditions *** - -Arg value is: this is a string -int(1) - -Arg value is: Array -preg_match(): Argument #2 ($subject) must be of type string, array given -preg_match(): Argument #2 ($subject) must be of type string, stdClass given -Done diff --git a/ext/pcre/tests/preg_replace_callback_array_error.phpt b/ext/pcre/tests/preg_replace_callback_array_error.phpt index 6298d081b1f..fc531b3b02a 100644 --- a/ext/pcre/tests/preg_replace_callback_array_error.phpt +++ b/ext/pcre/tests/preg_replace_callback_array_error.phpt @@ -9,41 +9,83 @@ function b() { // empty strings -var_dump(preg_replace_callback_array( - array( - "/a/" => 'b', - "" => function () { return "ok"; }), 'a')); +var_dump( + preg_replace_callback_array( + [ + '/a/' => 'b', + '' => function () { + return 'ok'; + }, + ], + 'a' + ) +); -var_dump(preg_replace_callback_array( - array( - "/a/" => 'b', - null => function () { return "ok"; }), 'a')); +var_dump( + preg_replace_callback_array( + [ + '/a/' => 'b', + null => function () { + return 'ok'; + }, + ], + 'a' + ) +); // backslashes -var_dump(preg_replace_callback_array( - array( - "/a/" => 'b', - "\\b\\" => function () { return "ok"; }), 'a')); +var_dump( + preg_replace_callback_array( + [ + '/a/' => 'b', + "\\b\\" => function () { + return 'ok'; + }, + ], + 'a' + ) +); // alphanumeric delimiters -var_dump(preg_replace_callback_array( - array( - "/a/" => 'b', - "aba" => function () { return "ok"; }), 'a')); +var_dump( + preg_replace_callback_array( + [ + '/a/' => 'b', + 'aba' => function () { + return 'ok'; + }, + ], + 'a' + ) +); -var_dump(preg_replace_callback_array( - array( - "/a/" => 'b', - "1b1" => function () { return "ok"; }), 'a')); +var_dump( + preg_replace_callback_array( + [ + '/a/' => 'b', + '1b1' => function () { + return 'ok'; + }, + ], + 'a' + ) +); // null character delimiter -var_dump(preg_replace_callback_array( - array( - "/a/" => 'b', - "\0b\0" => function () { return "ok"; }), 'a')); +var_dump( + preg_replace_callback_array( + [ + '/a/' => 'b', + "\0b\0" => function () { + return 'ok'; + }, + ], + 'a' + ) +); ?> --EXPECTF-- @@ -53,14 +95,14 @@ NULL Warning: preg_replace_callback_array(): Empty regular expression in %spreg_replace_callback_array_error.php on line %d NULL -Warning: preg_replace_callback_array(): Delimiter must not be alphanumeric, backslash, or NUL in %spreg_replace_callback_array_error.php on line %d +Warning: preg_replace_callback_array(): Delimiter must not be alphanumeric, backslash, or NUL byte in %spreg_replace_callback_array_error.php on line %d NULL -Warning: preg_replace_callback_array(): Delimiter must not be alphanumeric, backslash, or NUL in %spreg_replace_callback_array_error.php on line %d +Warning: preg_replace_callback_array(): Delimiter must not be alphanumeric, backslash, or NUL byte in %spreg_replace_callback_array_error.php on line %d NULL -Warning: preg_replace_callback_array(): Delimiter must not be alphanumeric, backslash, or NUL in %spreg_replace_callback_array_error.php on line %d +Warning: preg_replace_callback_array(): Delimiter must not be alphanumeric, backslash, or NUL byte in %spreg_replace_callback_array_error.php on line %d NULL -Warning: preg_replace_callback_array(): Delimiter must not be alphanumeric, backslash, or NUL in %spreg_replace_callback_array_error.php on line %d -NULL \ No newline at end of file +Warning: preg_replace_callback_array(): Delimiter must not be alphanumeric, backslash, or NUL byte in %spreg_replace_callback_array_error.php on line %d +NULL diff --git a/ext/pcre/tests/preg_replace_callback_error1.phpt b/ext/pcre/tests/preg_replace_callback_error1.phpt index bd659bec9e5..92e070cc59a 100644 --- a/ext/pcre/tests/preg_replace_callback_error1.phpt +++ b/ext/pcre/tests/preg_replace_callback_error1.phpt @@ -3,53 +3,56 @@ Test preg_replace_callback() function : error --FILE-- --EXPECTF-- -*** Testing preg_replace_callback() : error conditions *** -Arg value is abcdef - -Warning: preg_replace_callback(): Delimiter must not be alphanumeric, backslash, or NUL in %s on line %d +Warning: preg_replace_callback(): Delimiter must not be alphanumeric, backslash, or NUL byte in %s on line %d NULL -Arg value is /[a-zA-Z] - Warning: preg_replace_callback(): No ending delimiter '/' found in %s on line %d NULL -Arg value is [a-zA-Z]/ - Warning: preg_replace_callback(): Unknown modifier '/' in %s on line %d NULL -Arg value is /[a-zA-Z]/F - Warning: preg_replace_callback(): Unknown modifier 'F' in %s on line %d NULL - -Arg value is Array string(9) "number 1." - -Arg value is /[0-9]/ string(11) "number one." diff --git a/ext/pcre/tests/preg_replace_error1.phpt b/ext/pcre/tests/preg_replace_error1.phpt index 6ea93d15449..0a8a79751a9 100644 --- a/ext/pcre/tests/preg_replace_error1.phpt +++ b/ext/pcre/tests/preg_replace_error1.phpt @@ -3,22 +3,26 @@ Test preg_replace() function : error - bad regular expressions --FILE-- --EXPECTF-- -*** Testing preg_replace() : error conditions*** -Arg value is abcdef - -Warning: preg_replace(): Delimiter must not be alphanumeric, backslash, or NUL in %spreg_replace_error1.php on line %d +Warning: preg_replace(): Delimiter must not be alphanumeric, backslash, or NUL byte in %spreg_replace_error1.php on line %d NULL -Arg value is /[a-zA-Z] - Warning: preg_replace(): No ending delimiter '/' found in %spreg_replace_error1.php on line %d NULL -Arg value is [a-zA-Z]/ - Warning: preg_replace(): Unknown modifier '/' in %spreg_replace_error1.php on line %d NULL -Arg value is /[a-zA-Z]/F - Warning: preg_replace(): Unknown modifier 'F' in %spreg_replace_error1.php on line %d NULL - -Arg value is Array string(1) "a" - -Arg value is /[a-zA-Z]/ string(1) "1" preg_replace(): Argument #1 ($pattern) must be of type array|string, stdClass given diff --git a/ext/pcre/tests/preg_replace_error2.phpt b/ext/pcre/tests/preg_replace_error2.phpt index 4b162061b33..9bc36f655f4 100644 --- a/ext/pcre/tests/preg_replace_error2.phpt +++ b/ext/pcre/tests/preg_replace_error2.phpt @@ -8,12 +8,10 @@ Test preg_replace() function : error conditions - wrong arg types /* * Testing how preg_replace reacts to being passed the wrong type of replacement argument */ -echo "*** Testing preg_replace() : error conditions ***\n"; $regex = '/[a-zA-Z]/'; $replace = array('this is a string', array('this is', 'a subarray'),); $subject = 'test'; foreach($replace as $value) { - @print "\nArg value is: $value\n"; try { var_dump(preg_replace($regex, $value, $subject)); } catch (TypeError $e) { @@ -26,15 +24,8 @@ try { } catch (Error $e) { echo $e->getMessage(), "\n"; } -echo "Done"; ?> --EXPECT-- -*** Testing preg_replace() : error conditions *** - -Arg value is: this is a string string(64) "this is a stringthis is a stringthis is a stringthis is a string" - -Arg value is: Array preg_replace(): Argument #1 ($pattern) must be of type array when argument #2 ($replacement) is an array, string given preg_replace(): Argument #2 ($replacement) must be of type array|string, stdClass given -Done diff --git a/ext/pcre/tests/preg_split_error1.phpt b/ext/pcre/tests/preg_split_error1.phpt index 5ffb9f08ac3..6555f21366a 100644 --- a/ext/pcre/tests/preg_split_error1.phpt +++ b/ext/pcre/tests/preg_split_error1.phpt @@ -3,21 +3,25 @@ Test preg_split() function : error conditions - bad regular expressions --FILE-- --EXPECTF-- -*** Testing preg_split() : error conditions *** -Arg value is abcdef - -Warning: preg_split(): Delimiter must not be alphanumeric, backslash, or NUL in %spreg_split_error1.php on line %d +Warning: preg_split(): Delimiter must not be alphanumeric, backslash, or NUL byte in %spreg_split_error1.php on line %d bool(false) -Arg value is /[a-zA-Z] - Warning: preg_split(): No ending delimiter '/' found in %spreg_split_error1.php on line %d bool(false) -Arg value is [a-zA-Z]/ - Warning: preg_split(): Unknown modifier '/' in %spreg_split_error1.php on line %d bool(false) -Arg value is /[a-zA-Z]/F - Warning: preg_split(): Unknown modifier 'F' in %spreg_split_error1.php on line %d bool(false) - -Arg value is Array preg_split(): Argument #1 ($pattern) must be of type string, array given - -Arg value is /[a-zA-Z]/ array(3) { [0]=> string(4) "1 2 "