Skip to content

Commit 466fc78

Browse files
mvorisekiluuu1994
authored andcommitted
Mangle PCRE regex cache key with JIT option
Closes GH-11396
1 parent 2be4d91 commit 466fc78

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 8.1.22
44

5+
- PCRE:
6+
. Mangle PCRE regex cache key with JIT option. (mvorisek)
57

68
06 Jul 2023, PHP 8.1.21
79

ext/pcre/php_pcre.c

+16-3
Original file line numberDiff line numberDiff line change
@@ -627,11 +627,24 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
627627
pcre_cache_entry *ret;
628628

629629
if (locale_aware && BG(ctype_string)) {
630-
key = zend_string_concat2(
630+
key = zend_string_concat3(
631631
ZSTR_VAL(BG(ctype_string)), ZSTR_LEN(BG(ctype_string)),
632-
ZSTR_VAL(regex), ZSTR_LEN(regex));
632+
ZSTR_VAL(regex), ZSTR_LEN(regex),
633+
#ifdef HAVE_PCRE_JIT_SUPPORT
634+
PCRE_G(jit) ? "1" : "0", 1
635+
#else
636+
"", 0
637+
#endif
638+
);
633639
} else {
640+
#ifdef HAVE_PCRE_JIT_SUPPORT
641+
key = zend_string_concat2(
642+
ZSTR_VAL(regex), ZSTR_LEN(regex),
643+
PCRE_G(jit) ? "1" : "0", 1
644+
);
645+
#else
634646
key = regex;
647+
#endif
635648
}
636649

637650
/* Try to lookup the cached regex entry, and if successful, just pass
@@ -786,7 +799,7 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
786799
return NULL;
787800
}
788801

789-
if (key != regex) {
802+
if (locale_aware && BG(ctype_string)) {
790803
tables = (uint8_t *)zend_hash_find_ptr(&char_tables, BG(ctype_string));
791804
if (!tables) {
792805
zend_string *_k;

0 commit comments

Comments
 (0)