From 4be867e9103a415c598d5a15f95fec274d1b7825 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 18 Mar 2021 10:48:43 +0100 Subject: Fix locale switch back to C in pcre The compile context is shared between patterns, so we need to set the character tables unconditionally in case we switched from a non-C locale to the C locale. --- ext/pcre/php_pcre.c | 2 +- ext/pcre/tests/ctype_back_to_c.phpt | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 ext/pcre/tests/ctype_back_to_c.phpt diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index 19b1069978..7b38ac43d7 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -767,8 +767,8 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, in zend_hash_add_ptr(&char_tables, _k, (void *)tables); zend_string_release(_k); } - pcre2_set_character_tables(cctx, tables); } + pcre2_set_character_tables(cctx, tables); /* Set extra options for the compile context. */ if (PHP_PCRE_DEFAULT_EXTRA_COPTIONS != extra_coptions) { diff --git a/ext/pcre/tests/ctype_back_to_c.phpt b/ext/pcre/tests/ctype_back_to_c.phpt new file mode 100644 index 0000000000..b329091671 --- /dev/null +++ b/ext/pcre/tests/ctype_back_to_c.phpt @@ -0,0 +1,18 @@ +--TEST-- +Changing LC_CTYPE back to C +--SKIPIF-- + +--FILE-- + +--EXPECT-- +bool(true) +int(1) +bool(true) +int(0) -- cgit v1.2.1