Skip to content

Commit e839430

Browse files
committed
ext/pcre: Upgrade bundled PCRE2 to 10.49
Import PCRE2 10.49 and its pinned SLJIT sources, retaining PHP's configuration and symbol prefixes. Update both build systems and the reproducible importer, and cover the Unicode character-class regression that prompted the 10.44 rollback.
1 parent bd334e6 commit e839430

78 files changed

Lines changed: 32666 additions & 14130 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/scripts/download-bundled/pcre2.sh‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@ cd "$(dirname "$0")/../../.."
55
tmp_dir=/tmp/php-src-download-bundled/pcre2
66
rm -rf "$tmp_dir"
77

8-
revision=refs/tags/pcre2-10.44
8+
revision=refs/tags/pcre2-10.49
99

1010
git clone --depth 1 --recurse-submodules --revision="$revision" https://github.com/PCRE2Project/pcre2.git "$tmp_dir"
1111

1212
rm -rf ext/pcre/pcre2lib
1313
cp -R "$tmp_dir"/src ext/pcre/pcre2lib
14+
cp -R "$tmp_dir"/deps/sljit/sljit_src ext/pcre/pcre2lib/sljit
15+
sed 's|"../deps/sljit/sljit_src/sljitLir.c"|"sljit/sljitLir.c"|' \
16+
"$tmp_dir"/src/pcre2_jit_compile.c > ext/pcre/pcre2lib/pcre2_jit_compile.c
1417

1518
cd ext/pcre/pcre2lib
1619

1720
# remove unneeded files
21+
rm config-cmake.h.in
1822
rm config.h.generic
1923
rm pcre2.h.in
2024
rm pcre2_dftables.c
@@ -26,6 +30,9 @@ rm pcre2posix.c
2630
rm pcre2posix.h
2731
rm pcre2posix_test.c
2832
rm pcre2test.c
33+
rm pcre2test_inc.h
34+
rm pcre2_chartables.c.ebcdic-*
35+
rm libpcre2-*.sym.in
2936

3037
# move renamed files
3138
mv pcre2.h.generic pcre2.h

‎NEWS‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ PHP NEWS
8585
. Fixed bug GH-23986 (/proc/self paths resolve to the parent process after
8686
pcntl_fork()). (Lazizbek Ergashev)
8787

88+
- PCRE:
89+
. Upgraded bundled PCRE2 to 10.49. (Ilia Alshanetsky)
90+
8891
- PDO:
8992
. Fixed PDO::setAttribute() installing a PDO::ATTR_STATEMENT_CLASS class
9093
whose constructor arguments it rejects. (Ilia Alshanetsky)

‎UPGRADING‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ PHP 8.6 UPGRADE NOTES
119119
. preg_grep() now returns false instead of a partial array when a PCRE
120120
execution error occurs (e.g. malformed UTF-8 input with the /u modifier).
121121
This is consistent with other preg_* functions.
122+
. With the bundled PCRE2 library, case-insensitive matching of \p{Ll},
123+
\p{Lu}, and \p{Lt} now matches any cased letter.
124+
. A \x escape without a following hexadecimal digit or opening brace now
125+
causes a compilation error. Use \x00 to match the NUL character.
126+
. Unicode character properties in the bundled library now use Unicode 17.0.
122127

123128
- PGSQL:
124129
. pg_fetch_object() now reports the ValueError for a non-empty
@@ -958,6 +963,9 @@ PHP 8.6 UPGRADE NOTES
958963
- Opcache:
959964
. JIT is now supported for ZTS builds on Apple Silicon.
960965

966+
- PCRE:
967+
. The bundled PCRE2 library has been upgraded to version 10.49.
968+
961969
========================================
962970
10. New Global Constants
963971
========================================

‎ext/pcre/config.w32‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
EXTENSION("pcre", "php_pcre.c", false /* never shared */,
44
"-Iext/pcre/pcre2lib");
5-
ADD_SOURCES("ext/pcre/pcre2lib", "pcre2_auto_possess.c pcre2_chartables.c pcre2_compile.c pcre2_config.c pcre2_context.c pcre2_chkdint.c pcre2_dfa_match.c pcre2_error.c pcre2_jit_compile.c pcre2_maketables.c pcre2_match.c pcre2_match_data.c pcre2_newline.c pcre2_ord2utf.c pcre2_pattern_info.c pcre2_serialize.c pcre2_string_utils.c pcre2_study.c pcre2_substitute.c pcre2_substring.c pcre2_tables.c pcre2_ucd.c pcre2_valid_utf.c pcre2_xclass.c pcre2_find_bracket.c pcre2_convert.c pcre2_extuni.c pcre2_script_run.c", "pcre");
5+
ADD_SOURCES("ext/pcre/pcre2lib", "pcre2_auto_possess.c pcre2_chartables.c pcre2_compile.c pcre2_compile_cgroup.c pcre2_compile_class.c pcre2_config.c pcre2_context.c pcre2_chkdint.c pcre2_dfa_match.c pcre2_error.c pcre2_jit_compile.c pcre2_maketables.c pcre2_match.c pcre2_match_data.c pcre2_match_next.c pcre2_newline.c pcre2_ord2utf.c pcre2_pattern_info.c pcre2_serialize.c pcre2_string_utils.c pcre2_study.c pcre2_substitute.c pcre2_substring.c pcre2_tables.c pcre2_ucd.c pcre2_valid_utf.c pcre2_xclass.c pcre2_find_bracket.c pcre2_convert.c pcre2_extuni.c pcre2_script_run.c", "pcre");
66
ADD_DEF_FILE("ext\\pcre\\php_pcre.def");
77

88
AC_DEFINE('HAVE_BUNDLED_PCRE', 1, 'Define to 1 if PHP uses the bundled PCRE library.');

‎ext/pcre/config0.m4‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ else
6767
pcre2lib/pcre2_chartables.c
6868
pcre2lib/pcre2_chkdint.c
6969
pcre2lib/pcre2_compile.c
70+
pcre2lib/pcre2_compile_cgroup.c
71+
pcre2lib/pcre2_compile_class.c
7072
pcre2lib/pcre2_config.c
7173
pcre2lib/pcre2_context.c
7274
pcre2lib/pcre2_convert.c
@@ -78,6 +80,7 @@ else
7880
pcre2lib/pcre2_maketables.c
7981
pcre2lib/pcre2_match_data.c
8082
pcre2lib/pcre2_match.c
83+
pcre2lib/pcre2_match_next.c
8184
pcre2lib/pcre2_newline.c
8285
pcre2lib/pcre2_ord2utf.c
8386
pcre2lib/pcre2_pattern_info.c

‎ext/pcre/pcre2lib/pcre2.h‎

Lines changed: 94 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,40 +42,37 @@ POSSIBILITY OF SUCH DAMAGE.
4242
/* The current PCRE version information. */
4343

4444
#define PCRE2_MAJOR 10
45-
#define PCRE2_MINOR 44
45+
#define PCRE2_MINOR 49
4646
#define PCRE2_PRERELEASE
47-
#define PCRE2_DATE 2024-06-07
47+
#define PCRE2_DATE 2026-09-28
4848

49-
/* When an application links to a PCRE DLL in Windows, the symbols that are
49+
/* When an application links to a PCRE2 DLL in Windows, the symbols that are
5050
imported have to be identified as such. When building PCRE2, the appropriate
51-
export setting is defined in pcre2_internal.h, which includes this file. So we
52-
don't change existing definitions of PCRE2_EXP_DECL. */
51+
export setting is defined in pcre2_internal.h, which includes this file. So, we
52+
don't change existing definitions of PCRE2_EXP_DECL.
5353
54-
#if defined(_WIN32) && !defined(PCRE2_STATIC)
55-
# ifndef PCRE2_EXP_DECL
56-
# define PCRE2_EXP_DECL extern __declspec(dllimport)
57-
# endif
58-
#endif
59-
60-
/* By default, we use the standard "extern" declarations. */
54+
By default, we use the standard "extern" declarations. */
6155

6256
#ifndef PCRE2_EXP_DECL
63-
# ifdef __cplusplus
57+
# if defined(_WIN32) && !defined(PCRE2_STATIC)
58+
# define PCRE2_EXP_DECL extern __declspec(dllimport)
59+
# elif defined __cplusplus
6460
# define PCRE2_EXP_DECL extern "C"
6561
# else
6662
# define PCRE2_EXP_DECL extern
6763
# endif
6864
#endif
6965

7066
/* When compiling with the MSVC compiler, it is sometimes necessary to include
71-
a "calling convention" before exported function names. (This is secondhand
72-
information; I know nothing about MSVC myself). For example, something like
67+
a "calling convention" before exported function names. For example:
7368
7469
void __cdecl function(....)
7570
76-
might be needed. In order so make this easy, all the exported functions have
77-
PCRE2_CALL_CONVENTION just before their names. It is rarely needed; if not
78-
set, we ensure here that it has no effect. */
71+
might be needed. In order to make this easy, all the exported functions have
72+
PCRE2_CALL_CONVENTION just before their names.
73+
74+
PCRE2 normally uses the platform's standard calling convention, so this should
75+
not be set unless you know you need it. */
7976

8077
#ifndef PCRE2_CALL_CONVENTION
8178
#define PCRE2_CALL_CONVENTION
@@ -143,6 +140,7 @@ D is inspected during pcre2_dfa_match() execution
143140
#define PCRE2_EXTENDED_MORE 0x01000000u /* C */
144141
#define PCRE2_LITERAL 0x02000000u /* C */
145142
#define PCRE2_MATCH_INVALID_UTF 0x04000000u /* J M D */
143+
#define PCRE2_ALT_EXTENDED_CLASS 0x08000000u /* C */
146144

147145
/* An additional compile options word is available in the compile context. */
148146

@@ -159,13 +157,18 @@ D is inspected during pcre2_dfa_match() execution
159157
#define PCRE2_EXTRA_ASCII_BSW 0x00000400u /* C */
160158
#define PCRE2_EXTRA_ASCII_POSIX 0x00000800u /* C */
161159
#define PCRE2_EXTRA_ASCII_DIGIT 0x00001000u /* C */
160+
#define PCRE2_EXTRA_PYTHON_OCTAL 0x00002000u /* C */
161+
#define PCRE2_EXTRA_NO_BS0 0x00004000u /* C */
162+
#define PCRE2_EXTRA_NEVER_CALLOUT 0x00008000u /* C */
163+
#define PCRE2_EXTRA_TURKISH_CASING 0x00010000u /* C */
162164

163165
/* These are for pcre2_jit_compile(). */
164166

165167
#define PCRE2_JIT_COMPLETE 0x00000001u /* For full matching */
166168
#define PCRE2_JIT_PARTIAL_SOFT 0x00000002u
167169
#define PCRE2_JIT_PARTIAL_HARD 0x00000004u
168170
#define PCRE2_JIT_INVALID_UTF 0x00000100u
171+
#define PCRE2_JIT_TEST_ALLOC 0x00000200u
169172

170173
/* These are for pcre2_match(), pcre2_dfa_match(), pcre2_jit_match(), and
171174
pcre2_substitute(). Some are allowed only for one of the functions, and in
@@ -318,9 +321,29 @@ pcre2_pattern_convert(). */
318321
#define PCRE2_ERROR_ALPHA_ASSERTION_UNKNOWN 195
319322
#define PCRE2_ERROR_SCRIPT_RUN_NOT_AVAILABLE 196
320323
#define PCRE2_ERROR_TOO_MANY_CAPTURES 197
321-
#define PCRE2_ERROR_CONDITION_ATOMIC_ASSERTION_EXPECTED 198
324+
#define PCRE2_ERROR_MISSING_OCTAL_DIGIT 198
322325
#define PCRE2_ERROR_BACKSLASH_K_IN_LOOKAROUND 199
323-
326+
#define PCRE2_ERROR_MAX_VAR_LOOKBEHIND_EXCEEDED 200
327+
#define PCRE2_ERROR_PATTERN_COMPILED_SIZE_TOO_BIG 201
328+
#define PCRE2_ERROR_OVERSIZE_PYTHON_OCTAL 202
329+
#define PCRE2_ERROR_CALLOUT_CALLER_DISABLED 203
330+
#define PCRE2_ERROR_EXTRA_CASING_REQUIRES_UNICODE 204
331+
#define PCRE2_ERROR_TURKISH_CASING_REQUIRES_UTF 205
332+
#define PCRE2_ERROR_EXTRA_CASING_INCOMPATIBLE 206
333+
#define PCRE2_ERROR_ECLASS_NEST_TOO_DEEP 207
334+
#define PCRE2_ERROR_ECLASS_INVALID_OPERATOR 208
335+
#define PCRE2_ERROR_ECLASS_UNEXPECTED_OPERATOR 209
336+
#define PCRE2_ERROR_ECLASS_EXPECTED_OPERAND 210
337+
#define PCRE2_ERROR_ECLASS_MIXED_OPERATORS 211
338+
#define PCRE2_ERROR_ECLASS_HINT_SQUARE_BRACKET 212
339+
#define PCRE2_ERROR_PERL_ECLASS_UNEXPECTED_EXPR 213
340+
#define PCRE2_ERROR_PERL_ECLASS_EMPTY_EXPR 214
341+
#define PCRE2_ERROR_PERL_ECLASS_MISSING_CLOSE 215
342+
#define PCRE2_ERROR_PERL_ECLASS_UNEXPECTED_CHAR 216
343+
#define PCRE2_ERROR_EXPECTED_CAPTURE_GROUP 217
344+
#define PCRE2_ERROR_MISSING_OPENING_PARENTHESIS 218
345+
#define PCRE2_ERROR_MISSING_NUMBER_TERMINATOR 219
346+
#define PCRE2_ERROR_NULL_ERROROFFSET 220
324347

325348
/* "Expected" matching error codes: no match and partial match. */
326349

@@ -407,6 +430,15 @@ released, the numbers must not be changed. */
407430
#define PCRE2_ERROR_INTERNAL_DUPMATCH (-65)
408431
#define PCRE2_ERROR_DFA_UINVALID_UTF (-66)
409432
#define PCRE2_ERROR_INVALIDOFFSET (-67)
433+
#define PCRE2_ERROR_JIT_UNSUPPORTED (-68)
434+
#define PCRE2_ERROR_REPLACECASE (-69)
435+
#define PCRE2_ERROR_TOOLARGEREPLACE (-70)
436+
#define PCRE2_ERROR_DIFFSUBSPATTERN (-71)
437+
#define PCRE2_ERROR_DIFFSUBSSUBJECT (-72)
438+
#define PCRE2_ERROR_DIFFSUBSOFFSET (-73)
439+
#define PCRE2_ERROR_DIFFSUBSOPTIONS (-74)
440+
#define PCRE2_ERROR_BAD_BACKSLASH_K (-75)
441+
#define PCRE2_ERROR_PARTIALSUBS (-76)
410442

411443

412444
/* Request types for pcre2_pattern_info() */
@@ -459,7 +491,32 @@ released, the numbers must not be changed. */
459491
#define PCRE2_CONFIG_NEVER_BACKSLASH_C 13
460492
#define PCRE2_CONFIG_COMPILED_WIDTHS 14
461493
#define PCRE2_CONFIG_TABLES_LENGTH 15
494+
#define PCRE2_CONFIG_EFFECTIVE_LINKSIZE 16
495+
496+
/* Optimization directives for pcre2_set_optimize().
497+
For binary compatibility, only add to this list; do not renumber. */
498+
499+
#define PCRE2_OPTIMIZATION_NONE 0
500+
#define PCRE2_OPTIMIZATION_FULL 1
501+
502+
#define PCRE2_AUTO_POSSESS 64
503+
#define PCRE2_AUTO_POSSESS_OFF 65
504+
#define PCRE2_DOTSTAR_ANCHOR 66
505+
#define PCRE2_DOTSTAR_ANCHOR_OFF 67
506+
#define PCRE2_START_OPTIMIZE 68
507+
#define PCRE2_START_OPTIMIZE_OFF 69
462508

509+
/* Types used in pcre2_set_substitute_case_callout().
510+
511+
PCRE2_SUBSTITUTE_CASE_LOWER and PCRE2_SUBSTITUTE_CASE_UPPER are passed to the
512+
callout to indicate that the case of the entire callout input should be
513+
case-transformed. PCRE2_SUBSTITUTE_CASE_TITLE_FIRST is passed to indicate that
514+
only the first character or glyph should be transformed to Unicode titlecase,
515+
and the rest to lowercase. */
516+
517+
#define PCRE2_SUBSTITUTE_CASE_LOWER 1
518+
#define PCRE2_SUBSTITUTE_CASE_UPPER 2
519+
#define PCRE2_SUBSTITUTE_CASE_TITLE_FIRST 3
463520

464521
/* Types for code units in patterns and subject strings. */
465522

@@ -613,7 +670,9 @@ PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
613670
pcre2_set_parens_nest_limit(pcre2_compile_context *, uint32_t); \
614671
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
615672
pcre2_set_compile_recursion_guard(pcre2_compile_context *, \
616-
int (*)(uint32_t, void *), void *);
673+
int (*)(uint32_t, void *), void *); \
674+
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
675+
pcre2_set_optimize(pcre2_compile_context *, uint32_t);
617676

618677
#define PCRE2_MATCH_CONTEXT_FUNCTIONS \
619678
PCRE2_EXP_DECL pcre2_match_context *PCRE2_CALL_CONVENTION \
@@ -628,6 +687,11 @@ PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
628687
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
629688
pcre2_set_substitute_callout(pcre2_match_context *, \
630689
int (*)(pcre2_substitute_callout_block *, void *), void *); \
690+
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
691+
pcre2_set_substitute_case_callout(pcre2_match_context *, \
692+
PCRE2_SIZE (*)(PCRE2_SPTR, PCRE2_SIZE, PCRE2_UCHAR *, PCRE2_SIZE, int, \
693+
void *), \
694+
void *); \
631695
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
632696
pcre2_set_depth_limit(pcre2_match_context *, uint32_t); \
633697
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
@@ -687,14 +751,14 @@ PCRE2_EXP_DECL pcre2_match_data *PCRE2_CALL_CONVENTION \
687751
PCRE2_EXP_DECL pcre2_match_data *PCRE2_CALL_CONVENTION \
688752
pcre2_match_data_create_from_pattern(const pcre2_code *, \
689753
pcre2_general_context *); \
754+
PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \
755+
pcre2_match_data_free(pcre2_match_data *); \
690756
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
691757
pcre2_dfa_match(const pcre2_code *, PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, \
692758
uint32_t, pcre2_match_data *, pcre2_match_context *, int *, PCRE2_SIZE); \
693759
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
694760
pcre2_match(const pcre2_code *, PCRE2_SPTR, PCRE2_SIZE, PCRE2_SIZE, \
695761
uint32_t, pcre2_match_data *, pcre2_match_context *); \
696-
PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \
697-
pcre2_match_data_free(pcre2_match_data *); \
698762
PCRE2_EXP_DECL PCRE2_SPTR PCRE2_CALL_CONVENTION \
699763
pcre2_get_mark(pcre2_match_data *); \
700764
PCRE2_EXP_DECL PCRE2_SIZE PCRE2_CALL_CONVENTION \
@@ -706,7 +770,9 @@ PCRE2_EXP_DECL uint32_t PCRE2_CALL_CONVENTION \
706770
PCRE2_EXP_DECL PCRE2_SIZE *PCRE2_CALL_CONVENTION \
707771
pcre2_get_ovector_pointer(pcre2_match_data *); \
708772
PCRE2_EXP_DECL PCRE2_SIZE PCRE2_CALL_CONVENTION \
709-
pcre2_get_startchar(pcre2_match_data *);
773+
pcre2_get_startchar(pcre2_match_data *); \
774+
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
775+
pcre2_next_match(pcre2_match_data *, PCRE2_SIZE *, uint32_t *);
710776

711777

712778
/* Convenience functions for handling matched substrings. */
@@ -740,6 +806,7 @@ PCRE2_EXP_DECL void PCRE2_CALL_CONVENTION \
740806
PCRE2_EXP_DECL int PCRE2_CALL_CONVENTION \
741807
pcre2_substring_list_get(pcre2_match_data *, PCRE2_UCHAR ***, PCRE2_SIZE **);
742808

809+
743810
/* Functions for serializing / deserializing compiled patterns. */
744811

745812
#define PCRE2_SERIALIZE_FUNCTIONS \
@@ -885,6 +952,7 @@ pcre2_compile are called by application code. */
885952
#define pcre2_match_data_create PCRE2_SUFFIX(pcre2_match_data_create_)
886953
#define pcre2_match_data_create_from_pattern PCRE2_SUFFIX(pcre2_match_data_create_from_pattern_)
887954
#define pcre2_match_data_free PCRE2_SUFFIX(pcre2_match_data_free_)
955+
#define pcre2_next_match PCRE2_SUFFIX(pcre2_next_match_)
888956
#define pcre2_pattern_convert PCRE2_SUFFIX(pcre2_pattern_convert_)
889957
#define pcre2_pattern_info PCRE2_SUFFIX(pcre2_pattern_info_)
890958
#define pcre2_serialize_decode PCRE2_SUFFIX(pcre2_serialize_decode_)
@@ -907,7 +975,9 @@ pcre2_compile are called by application code. */
907975
#define pcre2_set_newline PCRE2_SUFFIX(pcre2_set_newline_)
908976
#define pcre2_set_parens_nest_limit PCRE2_SUFFIX(pcre2_set_parens_nest_limit_)
909977
#define pcre2_set_offset_limit PCRE2_SUFFIX(pcre2_set_offset_limit_)
978+
#define pcre2_set_optimize PCRE2_SUFFIX(pcre2_set_optimize_)
910979
#define pcre2_set_substitute_callout PCRE2_SUFFIX(pcre2_set_substitute_callout_)
980+
#define pcre2_set_substitute_case_callout PCRE2_SUFFIX(pcre2_set_substitute_case_callout_)
911981
#define pcre2_substitute PCRE2_SUFFIX(pcre2_substitute_)
912982
#define pcre2_substring_copy_byname PCRE2_SUFFIX(pcre2_substring_copy_byname_)
913983
#define pcre2_substring_copy_bynumber PCRE2_SUFFIX(pcre2_substring_copy_bynumber_)

0 commit comments

Comments
 (0)