Skip to content

Commit 4dce2f8

Browse files
committed
Merge branch 'PHP-7.4' into PHP-8.0
* PHP-7.4: Fix locale switch back to C in pcre
2 parents 7e494d9 + 4be867e commit 4dce2f8

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

ext/pcre/php_pcre.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,8 +790,8 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in
790790
zend_hash_add_ptr(&char_tables, _k, (void *)tables);
791791
zend_string_release(_k);
792792
}
793-
pcre2_set_character_tables(cctx, tables);
794793
}
794+
pcre2_set_character_tables(cctx, tables);
795795

796796
/* Compile pattern and display a warning if compilation failed. */
797797
re = pcre2_compile((PCRE2_SPTR)pattern, pattern_len, coptions, &errnumber, &erroffset, cctx);

ext/pcre/tests/ctype_back_to_c.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Changing LC_CTYPE back to C
3+
--SKIPIF--
4+
<?php
5+
if (!setlocale(LC_CTYPE, "de_DE", "de-DE")) die("skip requires de_DE locale");
6+
?>
7+
--FILE--
8+
<?php
9+
var_dump(setlocale(LC_CTYPE, "de_DE", "de-DE") !== false);
10+
var_dump(preg_match('/\w/', "\xe4"));
11+
var_dump(setlocale(LC_CTYPE, "C") !== false);
12+
var_dump(preg_match('/\w/', "\xe4"));
13+
?>
14+
--EXPECT--
15+
bool(true)
16+
int(1)
17+
bool(true)
18+
int(0)

0 commit comments

Comments
 (0)