Skip to content

pcre: Stop special-casing /e #12355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions ext/pcre/php_pcre.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@
#define PREG_SPLIT_DELIM_CAPTURE (1<<1)
#define PREG_SPLIT_OFFSET_CAPTURE (1<<2)

#define PREG_REPLACE_EVAL (1<<0)

#define PREG_GREP_INVERT (1<<0)

#define PREG_JIT (1<<3)
Expand Down Expand Up @@ -737,14 +735,12 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
break;
case 'J': coptions |= PCRE2_DUPNAMES; break;

/* Custom preg options */
case 'e': poptions |= PREG_REPLACE_EVAL; break;

case ' ':
case '\n':
case '\r':
break;

case 'e': /* legacy eval */
default:
if (pp[-1]) {
php_error_docref(NULL, E_WARNING, "Unknown modifier '%c'", pp[-1]);
Expand All @@ -760,16 +756,6 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
}
}

if (poptions & PREG_REPLACE_EVAL) {
php_error_docref(NULL, E_WARNING, "The /e modifier is no longer supported, use preg_replace_callback instead");
pcre_handle_exec_error(PCRE2_ERROR_INTERNAL);
efree(pattern);
if (key != regex) {
zend_string_release_ex(key, 0);
}
return NULL;
}

if (key != regex) {
tables = (uint8_t *)zend_hash_find_ptr(&char_tables, BG(ctype_string));
if (!tables) {
Expand Down
2 changes: 1 addition & 1 deletion ext/pcre/tests/002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ string(12) "a${1b${1c${1"
Warning: preg_replace(): Compilation failed: missing terminating ] for character class at offset 8 in %s002.php on line %d
NULL

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in %s on line %d
Warning: preg_replace(): Unknown modifier 'e' in %s on line %d
NULL
4 changes: 0 additions & 4 deletions ext/pcre/tests/null_bytes.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ var_dump(preg_match("[abc\0def]", "abc"));
var_dump(preg_match("[abc\0def]", "abc\0def"));
var_dump(preg_match("[abc\0def]", "abc\0fed"));

preg_replace("/foo/e\0/i", "echo('Eek');", "");

?>
--EXPECTF--
Warning: preg_match(): Delimiter must not be alphanumeric, backslash, or NUL in %snull_bytes.php on line 3
Expand Down Expand Up @@ -62,5 +60,3 @@ int(0)
int(0)
int(1)
int(0)

Warning: preg_replace(): NUL is not a valid modifier in %snull_bytes.php on line 27