blob: d27542d372fda567935d8061e16b5157d7186ef3 [file] [log] [blame]
Elliott Hughes5b808042021-10-01 10:56:10 -07001Change Log for PCRE2
2--------------------
3
Elliott Hughes16619d62021-10-29 12:10:38 -07004Version 10.39 29-October-2021
5-----------------------------
6
71. Fix incorrect detection of alternatives in first character search in JIT.
8
92. Merged patch from @carenas (GitHub #28):
10
11 Visual Studio 2013 includes support for %zu and %td, so let newer
12 versions of it avoid the fallback, and while at it, make sure that
13 the first check is for DISABLE_PERCENT_ZT so it will be always
14 honoured if chosen.
15
16 prtdiff_t is signed, so use a signed type instead, and make sure
17 that an appropiate width is chosen if pointers are 64bit wide and
18 long is not (ex: Windows 64bit).
19
20 IMHO removing the cast (and therefore the positibilty of truncation)
21 make the code cleaner and the fallback is likely portable enough
22 with all 64-bit POSIX systems doing LP64 except for Windows.
23
243. Merged patch from @carenas (GitHub #29) to update to Unicode 14.0.0.
25
264. Merged patch from @carenas (GitHub #30):
27
28 * Cleanup: remove references to no longer used stdint.h
29
30 Since 19c50b9d (Unconditionally use inttypes.h instead of trying for stdint.h
31 (simplification) and remove the now unnecessary inclusion in
32 pcre2_internal.h., 2018-11-14), stdint.h is no longer used.
33
34 Remove checks for it in autotools and CMake and document better the expected
35 build failures for systems that might have stdint.h (C99) and not inttypes.h
36 (from POSIX), like old Windows.
37
38 * Cleanup: remove detection for inttypes.h which is a hard dependency
39
40 CMake checks for standard headers are not meant to be used for hard
41 dependencies, so will prevent a possible fallback to work.
42
43 Alternatively, the header could be checked to make the configuration fail
44 instead of breaking the build, but that was punted, as it was missing anyway
45 from autotools.
46
475. Merged patch from @carenas (GitHub #32):
48
49 * jit: allow building with ancient MSVC versions
50
51 Visual Studio older than 2013 fails to build with JIT enabled, because it is
52 unable to parse non C89 compatible syntax, with mixed declarations and code.
53 While most recent compilers wouldn't even report this as a warning since it
54 is valid C99, it could be also made visible by adding to gcc/clang the
55 -Wdeclaration-after-statement flag at build time.
56
57 Move the code below the affected definitions.
58
59 * pcre2grep: avoid mixing declarations with code
60
61 Since d5a61ee8 (Patch to detect (and ignore) symlink loops in pcre2grep,
62 2021-08-28), code will fail to build in a strict C89 compiler.
63
64 Reformat slightly to make it C89 compatible again.
65
66
Elliott Hughes5b808042021-10-01 10:56:10 -070067Version 10.38 01-October-2021
68-----------------------------
69
701. Fix invalid single character repetition issues in JIT when the repetition
71is inside a capturing bracket and the bracket is preceeded by character
72literals.
73
742. Installed revised CMake configuration files provided by Jan-Willem Blokland.
75This extends the CMake build system to build both static and shared libraries
76in one go, builds the static library with PIC, and exposes PCRE2 libraries
77using the CMake config files. JWB provided these notes:
78
79- Introduced CMake variable BUILD_STATIC_LIBS to build the static library.
80
81- Make a small modification to config-cmake.h.in by removing the PCRE2_STATIC
82 variable. Added PCRE2_STATIC variable to the static build using the
83 target_compile_definitions() function.
84
85- Extended the CMake config files.
86
87 - Introduced CMake variable PCRE2_USE_STATIC_LIBS to easily switch between
88 the static and shared libraries.
89
90 - Added the PCRE_STATIC variable to the target compile definitions for the
91 import of the static library.
92
93Building static and shared libraries using MSVC results in a name clash of
94the libraries. Both static and shared library builds create, for example, the
95file pcre2-8.lib. Therefore, I decided to change the static library names by
96adding "-static". For example, pcre2-8.lib has become pcre2-8-static.lib.
97[Comment by PH: this is MSVC-specific. It doesn't happen on Linux.]
98
993. Increased the minimum release number for CMake to 3.0.0 because older than
1002.8.12 is deprecated (it was set to 2.8.5) and causes warnings. Even 3.0.0 is
101quite old; it was released in 2014.
102
1034. Implemented a modified version of Thomas Tempelmann's pcre2grep patch for
104detecting symlink loops. This is dependent on the availability of realpath(),
105which is now tested for in ./configure and CMakeLists.txt.
106
1075. Implemented a modified version of Thomas Tempelmann's patch for faster
108case-independent "first code unit" searches for unanchored patterns in 8-bit
109mode in the interpreters. Instead of just remembering whether one case matched
110or not, it remembers the position of a previous match so as to avoid
111unnecessary repeated searching.
112
1136. Perl now locks out \K in lookarounds, so PCRE2 now does the same by default.
114However, just in case anybody was relying on the old behaviour, there is an
115option called PCRE2_EXTRA_ALLOW_LOOKAROUND_BSK that enables the old behaviour.
116An option has also been added to pcre2grep to enable this.
117
1187. Re-enable a JIT optimization which was unintentionally disabled in 10.35.
119
1208. There is a loop counter to catch excessively crazy patterns when checking
121the lengths of lookbehinds at compile time. This was incorrectly getting reset
122whenever a lookahead was processed, leading to some fuzzer-generated patterns
123taking a very long time to compile when (?|) was present in the pattern,
124because (?|) disables caching of group lengths.
125
126
127Version 10.37 26-May-2021
128-------------------------
129
1301. Change RunGrepTest to use tr instead of sed when testing with binary
131zero bytes, because sed varies a lot from system to system and has problems
132with binary zeros. This is from Bugzilla #2681. Patch from Jeremie
133Courreges-Anglas via Nam Nguyen. This fixes RunGrepTest for OpenBSD. Later:
134it broke it for at least one version of Solaris, where tr can't handle binary
135zeros. However, that system had /usr/xpg4/bin/tr installed, which works OK, so
136RunGrepTest now checks for that command and uses it if found.
137
1382. Compiling with gcc 10.2's -fanalyzer option showed up a hypothetical problem
139with a NULL dereference. I don't think this case could ever occur in practice,
140but I have put in a check in order to get rid of the compiler error.
141
1423. An alternative patch for CMakeLists.txt because 10.36 #4 breaks CMake on
143Windows. Patch from email@cs-ware.de fixes bugzilla #2688.
144
1454. Two bugs related to over-large numbers have been fixed so the behaviour is
146now the same as Perl.
147
148 (a) A pattern such as /\214748364/ gave an overflow error instead of being
149 treated as the octal number \214 followed by literal digits.
150
151 (b) A sequence such as {65536 that has no terminating } so is not a
152 quantifier was nevertheless complaining that a quantifier number was too big.
153
1545. A run of autoconf suggested that configure.ac was out-of-date with respect
155to the lastest autoconf. Running autoupdate made some valid changes, some valid
156suggestions, and also some invalid changes, which were fixed by hand. Autoconf
157now runs clean and the resulting "configure" seems to work, so I hope nothing
158is broken. Later: the requirement for autoconf 2.70 broke some automatic test
159robots. It doesn't seem to be necessary: trying a reduction to 2.60.
160
1616. The pattern /a\K.(?0)*/ when matched against "abac" by the interpreter gave
162the answer "bac", whereas Perl and JIT both yield "c". This was because the
163effect of \K was not propagating back from the full pattern recursion. Other
164recursions such as /(a\K.(?1)*)/ did not have this problem.
165
1667. Restore single character repetition optimization in JIT. Currently fewer
167character repetitions are optimized than in 10.34.
168
1698. When the names of the functions in the POSIX wrapper were changed to
170pcre2_regcomp() etc. (see change 10.33 #4 below), functions with the original
171names were left in the library so that pre-compiled programs would still work.
172However, this has proved troublesome when programs link with several libraries,
173some of which use PCRE2 via the POSIX interface while others use a native POSIX
174library. For this reason, the POSIX function names are removed in this release.
175The macros in pcre2posix.h should ensure that re-compiling fixes any programs
176that haven't been compiled since before 10.33.
177
178
179Version 10.36 04-December-2020
180------------------------------
181
1821. Add CET_CFLAGS so that when Intel CET is enabled, pass -mshstk to
183compiler. This fixes https://bugs.exim.org/show_bug.cgi?id=2578. Patch for
184Makefile.am and configure.ac by H.J. Lu. Equivalent patch for CMakeLists.txt
185invented by PH.
186
1872. Fix inifinite loop when a single byte newline is searched in JIT when
188invalid utf8 mode is enabled.
189
1903. Updated CMakeLists.txt with patch from Wolfgang Stöggl (Bugzilla #2584):
191
192 - Include GNUInstallDirs and use ${CMAKE_INSTALL_LIBDIR} instead of hardcoded
193 lib. This allows differentiation between lib and lib64.
194 CMAKE_INSTALL_LIBDIR is used for installation of libraries and also for
195 pkgconfig file generation.
196
197 - Add the version of PCRE2 to the configuration summary like ./configure
198 does.
199
200 - Fix typo: MACTHED_STRING->MATCHED_STRING
201
2024. Updated CMakeLists.txt with another patch from Wolfgang Stöggl (Bugzilla
203#2588):
204
205 - Add escaped double quotes around include directory in CMakeLists.txt to
206 allow spaces in directory names.
207
208 - This fixes a cmake error, if the path of the pcre2 source contains a space.
209
2105. Updated CMakeLists.txt with a patch from B. Scott Michel: CMake's
211documentation suggests using CHECK_SYMBOL_EXISTS over CHECK_FUNCTION_EXIST.
212Moreover, these functions come from specific header files, which need to be
213specified (and, thankfully, are the same on both the Linux and WinXX
214platforms.)
215
2166. Added a (uint32_t) cast to prevent a compiler warning in pcre2_compile.c.
217
2187. Applied a patch from Wolfgang Stöggl (Bugzilla #2600) to fix postfix for
219debug Windows builds using CMake. This also updated configure so that it
220generates *.pc files and pcre2-config with the same content, as in the past.
221
2228. If a pattern ended with (?(VERSION=n.d where n is any number but d is just a
223single digit, the code unit beyond d was being read (i.e. there was a read
224buffer overflow). Fixes ClusterFuzz 23779.
225
2269. After the rework in r1235, certain character ranges were incorrectly
227handled by an optimization in JIT. Furthermore a wrong offset was used to
228read a value from a buffer which could lead to memory overread.
229
23010. Unnoticed for many years was the fact that delimiters other than / in the
231testinput1 and testinput4 files could cause incorrect behaviour when these
232files were processed by perltest.sh. There were several tests that used quotes
233as delimiters, and it was just luck that they didn't go wrong with perltest.sh.
234All the patterns in testinput1 and testinput4 now use / as their delimiter.
235This fixes Bugzilla #2641.
236
23711. Perl has started to give an error for \K within lookarounds (though there
238are cases where it doesn't). PCRE2 still allows this, so the tests that include
239this case have been moved from test 1 to test 2.
240
24112. Further to 10 above, pcre2test has been updated to detect and grumble if a
242delimiter other than / is used after #perltest.
243
24413. Fixed a bug with PCRE2_MATCH_INVALID_UTF in 8-bit mode when PCRE2_CASELESS
245was set and PCRE2_NO_START_OPTIMIZE was not set. The optimization for finding
246the start of a match was not resetting correctly after a failed match on the
247first valid fragment of the subject, possibly causing incorrect "no match"
248returns on subsequent fragments. For example, the pattern /A/ failed to match
249the subject \xe5A. Fixes Bugzilla #2642.
250
25114. Fixed a bug in character set matching when JIT is enabled and both unicode
252scripts and unicode classes are present at the same time.
253
25415. Added GNU grep's -m (aka --max-count) option to pcre2grep.
255
25616. Refactored substitution processing in pcre2grep strings, both for the -O
257option and when dealing with callouts. There is now a single function that
258handles $ expansion in all cases (instead of multiple copies of almost
259identical code). This means that the same escape sequences are available
260everywhere, which was not previously the case. At the same time, the escape
261sequences $x{...} and $o{...} have been introduced, to allow for characters
262whose code points are greater than 255 in Unicode mode.
263
26417. Applied the patch from Bugzilla #2628 to RunGrepTest. This does an explicit
265test for a version of sed that can handle binary zero, instead of assuming that
266any Linux version will work. Later: replaced $(...) by `...` because not all
267shells recognize the former.
268
26918. Fixed a word boundary check bug in JIT when partial matching is enabled.
270
27119. Fix ARM64 compilation warning in JIT. Patch by Carlo.
272
27320. A bug in the RunTest script meant that if the first part of test 2 failed,
274the failure was not reported.
275
27621. Test 2 was failing when run from a directory other than the source
277directory. This failure was previously missed in RunTest because of 20 above.
278Fixes added to both RunTest and RunTest.bat.
279
28022. Patch to CMakeLists.txt from Daniel to fix problem with testing under
281Windows.
282
283
284Version 10.35 09-May-2020
285---------------------------
286
2871. Use PCRE2_MATCH_EMPTY flag to detect empty matches in JIT.
288
2892. Fix ARMv5 JIT improper handling of labels right after a constant pool.
290
2913. A JIT bug is fixed which allowed to read the fields of the compiled
292pattern before its existence is checked.
293
2944. Back in the PCRE1 day, capturing groups that contained recursive back
295references to themselves were made atomic (version 8.01, change 18) because
296after the end a repeated group, the captured substrings had their values from
297the final repetition, not from an earlier repetition that might be the
298destination of a backtrack. This feature was documented, and was carried over
299into PCRE2. However, it has now been realized that the major refactoring that
300was done for 10.30 has made this atomicizing unnecessary, and it is confusing
301when users are unaware of it, making some patterns appear not to be working as
302expected. Capture values of recursive back references in repeated groups are
303now correctly backtracked, so this unnecessary restriction has been removed.
304
3055. Added PCRE2_SUBSTITUTE_LITERAL.
306
3076. Avoid some VS compiler warnings.
308
3097. Added PCRE2_SUBSTITUTE_MATCHED.
310
3118. Added (?* and (?<* as synonms for (*napla: and (*naplb: to match another
312regex engine. The Perl regex folks are aware of this usage and have made a note
313about it.
314
3159. When an assertion is repeated, PCRE2 used to limit the maximum repetition to
3161, believing that repeating an assertion is pointless. However, if a positive
317assertion contains capturing groups, repetition can be useful. In any case, an
318assertion could always be wrapped in a repeated group. The only restriction
319that is now imposed is that an unlimited maximum is changed to one more than
320the minimum.
321
32210. Fix *THEN verbs in lookahead assertions in JIT.
323
32411. Added PCRE2_SUBSTITUTE_REPLACEMENT_ONLY.
325
32612. The JIT stack should be freed when the low-level stack allocation fails.
327
32813. In pcre2grep, if the final line in a scanned file is output but does not
329end with a newline sequence, add a newline according to the --newline setting.
330
33114. (?(DEFINE)...) groups were not being handled correctly when checking for
332the fixed length of a lookbehind assertion. Such a group within a lookbehind
333should be skipped, as it does not contribute to the length of the group.
334Instead, the (DEFINE) group was being processed, and if at the end of the
335lookbehind, that end was not correctly recognized. Errors such as "lookbehind
336assertion is not fixed length" and also "internal error: bad code value in
337parsed_skip()" could result.
338
33915. Put a limit of 1000 on recursive calls in pcre2_study() when searching
340nested groups for starting code units, in order to avoid stack overflow issues.
341If the limit is reached, it just gives up trying for this optimization.
342
34316. The control verb chain list must always be restored when exiting from a
344recurse function in JIT.
345
34617. Fix a crash which occurs when the character type of an invalid UTF
347character is decoded in JIT.
348
34918. Changes in many areas of the code so that when Unicode is supported and
350PCRE2_UCP is set without PCRE2_UTF, Unicode character properties are used for
351upper/lower case computations on characters whose code points are greater than
352127.
353
35419. The function for checking UTF-16 validity was returning an incorrect offset
355for the start of the error when a high surrogate was not followed by a valid
356low surrogate. This caused incorrect behaviour, for example when
357PCRE2_MATCH_INVALID_UTF was set and a match started immediately following the
358invalid high surrogate, such as /aa/ matching "\x{d800}aa".
359
36020. If a DEFINE group immediately preceded a lookbehind assertion, the pattern
361could be mis-compiled and therefore not match correctly. This is the example
362that found this: /(?(DEFINE)(?<foo>bar))(?<![-a-z0-9])word/ which failed to
363match "word" because the "move back" value was set to zero.
364
36521. Following a request from a user, some extensions and tidies to the
366character tables handling have been done:
367
368 (a) The dftables auxiliary program is renamed pcre2_dftables, but it is still
369 not installed for public use.
370
371 (b) There is now a -b option for pcre2_dftables, which causes the tables to
372 be written in binary. There is also a -help option.
373
374 (c) PCRE2_CONFIG_TABLES_LENGTH is added to pcre2_config() so that an
375 application that wants to save tables in binary knows how long they are.
376
37722. Changed setting of CMAKE_MODULE_PATH in CMakeLists.txt from SET to
378LIST(APPEND...) to allow a setting from the command line to be included.
379
38023. Updated to Unicode 13.0.0.
381
38224. CMake build now checks for secure_getenv() and strerror(). Patch by Carlo.
383
38425. Avoid using [-1] as a suffix in pcre2test because it can provoke a compiler
385warning.
386
38726. Added tests for __attribute__((uninitialized)) to both the configure and
388CMake build files, and then applied this attribute to the variable called
389stack_frames_vector[] in pcre2_match(). When implemented, this disables
390automatic initialization (a facility in clang), which can take time on big
391variables.
392
39327. Updated CMakeLists.txt (patches by Uwe Korn) to add support for
394pcre2-config, the libpcre*.pc files, SOVERSION, VERSION and the
395MACHO_*_VERSIONS settings for CMake builds.
396
39728. Another patch to CMakeLists.txt to check for mkostemp (configure already
398does). Patch by Carlo Marcelo Arenas Belon.
399
40029. Check for the existence of memfd_create in both CMake and configure
401configurations. Patch by Carlo Marcelo Arenas Belon.
402
40330. Restrict the configuration setting for the SELinux compatible execmem
404allocator (change 10.30/44) to Linux and NetBSD.
405
406
407Version 10.34 21-November-2019
408------------------------------
409
4101. The maximum number of capturing subpatterns is 65535 (documented), but no
411check on this was ever implemented. This omission has been rectified; it fixes
412ClusterFuzz 14376.
413
4142. Improved the invalid utf32 support of the JIT compiler. Now it correctly
415detects invalid characters in the 0xd800-0xdfff range.
416
4173. Fix minor typo bug in JIT compile when \X is used in a non-UTF string.
418
4194. Add support for matching in invalid UTF strings to the pcre2_match()
420interpreter, and integrate with the existing JIT support via the new
421PCRE2_MATCH_INVALID_UTF compile-time option.
422
4235. Give more error detail for invalid UTF-8 when detected in pcre2grep.
424
4256. Add support for invalid UTF-8 to pcre2grep.
426
4277. Adjust the limit for "must have" code unit searching, in particular,
428increase it substantially for non-anchored patterns.
429
4308. Allow (*ACCEPT) to be quantified, because an ungreedy quantifier with a zero
431minimum is potentially useful.
432
4339. Some changes to the way the minimum subject length is handled:
434
435 * When PCRE2_NO_START_OPTIMIZE is set, no minimum length is computed;
436 pcre2test now omits this item instead of showing a value of zero.
437
438 * An incorrect minimum length could be calculated for a pattern that
439 contained (*ACCEPT) inside a qualified group whose minimum repetition was
440 zero, for example /A(?:(*ACCEPT))?B/, which incorrectly computed a minimum
441 of 2. The minimum length scan no longer happens for a pattern that
442 contains (*ACCEPT).
443
444 * When no minimum length is set by the normal scan, but a first and/or last
445 code unit is recorded, set the minimum to 1 or 2 as appropriate.
446
447 * When a pattern contains multiple groups with the same number, a back
448 reference cannot know which one to scan for a minimum length. This used to
449 cause the minimum length finder to give up with no result. Now it treats
450 such references as not adding to the minimum length (which it should have
451 done all along).
452
453 * Furthermore, the above action now happens only if the back reference is to
454 a group that exists more than once in a pattern instead of any back
455 reference in a pattern with duplicate numbers.
456
45710. A (*MARK) value inside a successful condition was not being returned by the
458interpretive matcher (it was returned by JIT). This bug has been mended.
459
46011. A bug in pcre2grep meant that -o without an argument (or -o0) didn't work
461if the pattern had more than 32 capturing parentheses. This is fixed. In
462addition (a) the default limit for groups requested by -o<n> has been raised to
46350, (b) the new --om-capture option changes the limit, (c) an error is raised
464if -o asks for a group that is above the limit.
465
46612. The quantifier {1} was always being ignored, but this is incorrect when it
467is made possessive and applied to an item in parentheses, because a
468parenthesized item may contain multiple branches or other backtracking points,
469for example /(a|ab){1}+c/ or /(a+){1}+a/.
470
47113. For partial matches, pcre2test was always showing the maximum lookbehind
472characters, flagged with "<", which is misleading when the lookbehind didn't
473actually look behind the start (because it was later in the pattern). Showing
474all consulted preceding characters for partial matches is now controlled by the
475existing "allusedtext" modifier and, as for complete matches, this facility is
476available only for non-JIT matching, because JIT does not maintain the first
477and last consulted characters.
478
47914. DFA matching (using pcre2_dfa_match()) was not recognising a partial match
480if the end of the subject was encountered in a lookahead (conditional or
481otherwise), an atomic group, or a recursion.
482
48315. Give error if pcre2test -t, -T, -tm or -TM is given an argument of zero.
484
48516. Check for integer overflow when computing lookbehind lengths. Fixes
486Clusterfuzz issue 15636.
487
48817. Implemented non-atomic positive lookaround assertions.
489
49018. If a lookbehind contained a lookahead that contained another lookbehind
491within it, the nested lookbehind was not correctly processed. For example, if
492/(?<=(?=(?<=a)))b/ was matched to "ab" it gave no match instead of matching
493"b".
494
49519. Implemented pcre2_get_match_data_size().
496
49720. Two alterations to partial matching:
498
499 (a) The definition of a partial match is slightly changed: if a pattern
500 contains any lookbehinds, an empty partial match may be given, because this
501 is another situation where adding characters to the current subject can
502 lead to a full match. Example: /c*+(?<=[bc])/ with subject "ab".
503
504 (b) Similarly, if a pattern could match an empty string, an empty partial
505 match may be given. Example: /(?![ab]).*/ with subject "ab". This case
506 applies only to PCRE2_PARTIAL_HARD.
507
508 (c) An empty string partial hard match can be returned for \z and \Z as it
509 is documented that they shouldn't match.
510
51121. A branch that started with (*ACCEPT) was not being recognized as one that
512could match an empty string.
513
51422. Corrected pcre2_set_character_tables() tables data type: was const unsigned
515char * instead of const uint8_t *, as generated by pcre2_maketables().
516
51723. Upgraded to Unicode 12.1.0.
518
51924. Add -jitfast command line option to pcre2test (to make all the jit options
520available directly).
521
52225. Make pcre2test -C show if libreadline or libedit is supported.
523
52426. If the length of one branch of a group exceeded 65535 (the maximum value
525that is remembered as a minimum length), the whole group's length was
526incorrectly recorded as 65535, leading to incorrect "no match" when start-up
527optimizations were in force.
528
52927. The "rightmost consulted character" value was not always correct; in
530particular, if a pattern ended with a negative lookahead, characters that were
531inspected in that lookahead were not included.
532
53328. Add the pcre2_maketables_free() function.
534
53529. The start-up optimization that looks for a unique initial matching
536code unit in the interpretive engines uses memchr() in 8-bit mode. When the
537search is caseless, it was doing so inefficiently, which ended up slowing down
538the match drastically when the subject was very long. The revised code (a)
539remembers if one case is not found, so it never repeats the search for that
540case after a bumpalong and (b) when one case has been found, it searches only
541up to that position for an earlier occurrence of the other case. This fix
542applies to both interpretive pcre2_match() and to pcre2_dfa_match().
543
54430. While scanning to find the minimum length of a group, if any branch has
545minimum length zero, there is no need to scan any subsequent branches (a small
546compile-time performance improvement).
547
54831. Installed a .gitignore file on a user's suggestion. When using the svn
549repository with git (through git svn) this helps keep it tidy.
550
55132. Add underflow check in JIT which may occur when the value of subject
552string pointer is close to 0.
553
55433. Arrange for classes such as [Aa] which contain just the two cases of the
555same character, to be treated as a single caseless character. This causes the
556first and required code unit optimizations to kick in where relevant.
557
55834. Improve the bitmap of starting bytes for positive classes that include wide
559characters, but no property types, in UTF-8 mode. Previously, on encountering
560such a class, the bits for all bytes greater than \xc4 were set, thus
561specifying any character with codepoint >= 0x100. Now the only bits that are
562set are for the relevant bytes that start the wide characters. This can give a
563noticeable performance improvement.
564
56535. If the bitmap of starting code units contains only 1 or 2 bits, replace it
566with a single starting code unit (1 bit) or a caseless single starting code
567unit if the two relevant characters are case-partners. This is particularly
568relevant to the 8-bit library, though it applies to all. It can give a
569performance boost for patterns such as [Ww]ord and (word|WORD). However, this
570optimization doesn't happen if there is a "required" code unit of the same
571value (because the search for a "required" code unit starts at the match start
572for non-unique first code unit patterns, but after a unique first code unit,
573and patterns such as a*a need the former action).
574
57536. Small patch to pcre2posix.c to set the erroroffset field to -1 immediately
576after a successful compile, instead of at the start of matching to avoid a
577sanitizer complaint (regexec is supposed to be thread safe).
578
57937. Add NEON vectorization to JIT to speed up matching of first character and
580pairs of characters on ARM64 CPUs.
581
58238. If a non-ASCII character was the first in a starting assertion in a
583caseless match, the "first code unit" optimization did not get the casing
584right, and the assertion failed to match a character in the other case if it
585did not start with the same code unit.
586
58739. Fixed the incorrect computation of jump sizes on x86 CPUs in JIT. A masking
588operation was incorrectly removed in r1136. Reported by Ralf Junker.
589
590
591Version 10.33 16-April-2019
592---------------------------
593
5941. Added "allvector" to pcre2test to make it easy to check the part of the
595ovector that shouldn't be changed, in particular after substitute and failed or
596partial matches.
597
5982. Fix subject buffer overread in JIT when UTF is disabled and \X or \R has
599a greater than 1 fixed quantifier. This issue was found by Yunho Kim.
600
6013. Added support for callouts from pcre2_substitute(). After 10.33-RC1, but
602prior to release, fixed a bug that caused a crash if pcre2_substitute() was
603called with a NULL match context.
604
6054. The POSIX functions are now all called pcre2_regcomp() etc., with wrapper
606functions that use the standard POSIX names. However, in pcre2posix.h the POSIX
607names are defined as macros. This should help avoid linking with the wrong
608library in some environments while still exporting the POSIX names for
609pre-existing programs that use them. (The Debian alternative names are also
610defined as macros, but not documented.)
611
6125. Fix an xclass matching issue in JIT.
613
6146. Implement PCRE2_EXTRA_ESCAPED_CR_IS_LF (see Bugzilla 2315).
615
6167. Implement the Perl 5.28 experimental alphabetic names for atomic groups and
617lookaround assertions, for example, (*pla:...) and (*atomic:...). These are
618characterized by a lower case letter following (* and to simplify coding for
619this, the character tables created by pcre2_maketables() were updated to add a
620new "is lower case letter" bit. At the same time, the now unused "is
621hexadecimal digit" bit was removed. The default tables in
622src/pcre2_chartables.c.dist are updated.
623
6248. Implement the new Perl "script run" features (*script_run:...) and
625(*atomic_script_run:...) aka (*sr:...) and (*asr:...).
626
6279. Fixed two typos in change 22 for 10.21, which added special handling for
628ranges such as a-z in EBCDIC environments. The original code probably never
629worked, though there were no bug reports.
630
63110. Implement PCRE2_COPY_MATCHED_SUBJECT for pcre2_match() (including JIT via
632pcre2_match()) and pcre2_dfa_match(), but *not* the pcre2_jit_match() fast
633path. Also, when a match fails, set the subject field in the match data to NULL
634for tidiness - none of the substring extractors should reference this after
635match failure.
636
63711. If a pattern started with a subroutine call that had a quantifier with a
638minimum of zero, an incorrect "match must start with this character" could be
639recorded. Example: /(?&xxx)*ABC(?<xxx>XYZ)/ would (incorrectly) expect 'A' to
640be the first character of a match.
641
64212. The heap limit checking code in pcre2_dfa_match() could suffer from
643overflow if the heap limit was set very large. This could cause incorrect "heap
644limit exceeded" errors.
645
64613. Add "kibibytes" to the heap limit output from pcre2test -C to make the
647units clear.
648
64914. Add a call to pcre2_jit_free_unused_memory() in pcre2grep, for tidiness.
650
65115. Updated the VMS-specific code in pcre2test on the advice of a VMS user.
652
65316. Removed the unnecessary inclusion of stdint.h (or inttypes.h) from
654pcre2_internal.h as it is now included by pcre2.h. Also, change 17 for 10.32
655below was unnecessarily complicated, as inttypes.h is a Standard C header,
656which is defined to be a superset of stdint.h. Instead of conditionally
657including stdint.h or inttypes.h, pcre2.h now unconditionally includes
658inttypes.h. This supports environments that do not have stdint.h but do have
659inttypes.h, which are known to exist. A note in the autotools documentation
660says (November 2018) that there are none known that are the other way round.
661
66217. Added --disable-percent-zt to "configure" (and equivalent to CMake) to
663forcibly disable the use of %zu and %td in formatting strings because there is
664at least one version of VMS that claims to be C99 but does not support these
665modifiers.
666
66718. Added --disable-pcre2grep-callout-fork, which restricts the callout support
668in pcre2grep to the inbuilt echo facility. This may be useful in environments
669that do not support fork().
670
67119. Fix two instances of <= 0 being applied to unsigned integers (the VMS
672compiler complains).
673
67420. Added "fork" support for VMS to pcre2grep, for running an external program
675via a string callout.
676
67721. Improve MAP_JIT flag usage on MacOS. Patch by Rich Siegel.
678
67922. If a pattern started with (*MARK), (*COMMIT), (*PRUNE), (*SKIP), or (*THEN)
680followed by ^ it was not recognized as anchored.
681
68223. The RunGrepTest script used to cut out the test of NUL characters for
683Solaris and MacOS as printf and sed can't handle them. It seems that the *BSD
684systems can't either. I've inverted the test so that only those OS that are
685known to work (currently only Linux) try to run this test.
686
68724. Some tests in RunGrepTest appended to testtrygrep from two different file
688descriptors instead of redirecting stderr to stdout. This worked on Linux, but
689it was reported not to on other systems, causing the tests to fail.
690
69125. In the RunTest script, make the test for stack setting use the same value
692for the stack as it needs for -bigstack.
693
69426. Insert a cast in pcre2_dfa_match.c to suppress a compiler warning.
695
69626. With PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL set, escape sequences such as \s
697which are valid in character classes, but not as the end of ranges, were being
698treated as literals. An example is [_-\s] (but not [\s-_] because that gave an
699error at the *start* of a range). Now an "invalid range" error is given
700independently of PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL.
701
70227. Related to 26 above, PCRE2_BAD_ESCAPE_IS_LITERAL was affecting known escape
703sequences such as \eX when they appeared invalidly in a character class. Now
704the option applies only to unrecognized or malformed escape sequences.
705
70628. Fix word boundary in JIT compiler. Patch by Mike Munday.
707
70829. The pcre2_dfa_match() function was incorrectly handling conditional version
709tests such as (?(VERSION>=0)...) when the version test was true. Incorrect
710processing or a crash could result.
711
71230. When PCRE2_UTF is set, allow non-ASCII letters and decimal digits in group
713names, as Perl does. There was a small bug in this new code, found by
714ClusterFuzz 12950, fixed before release.
715
71631. Implemented PCRE2_EXTRA_ALT_BSUX to support ECMAScript 6's \u{hhh}
717construct.
718
71932. Compile \p{Any} to be the same as . in DOTALL mode, so that it benefits
720from auto-anchoring if \p{Any}* starts a pattern.
721
72233. Compile invalid UTF check in JIT test when only pcre32 is enabled.
723
72434. For some time now, CMake has been warning about the setting of policy
725CMP0026 to "OLD" in CmakeLists.txt, and hinting that the feature might be
726removed in a future version. A request for CMake expertise on the list produced
727no result, so I have now hacked CMakeLists.txt along the lines of some changes
728I found on the Internet. The new code no longer needs the policy setting, and
729it appears to work fine on Linux.
730
73135. Setting --enable-jit=auto for an out-of-tree build failed because the
732source directory wasn't in the search path for AC_TRY_COMPILE always. Patch
733from Ross Burton.
734
73536. Disable SSE2 JIT optimizations in x86 CPUs when SSE2 is not available.
736Patch by Guillem Jover.
737
73837. Changed expressions such as 1<<10 to 1u<<10 in many places because compiler
739warnings were reported.
740
74138. Using the clang compiler with sanitizing options causes runtime complaints
742about truncation for statments such as x = ~x when x is an 8-bit value; it
743seems to compute ~x as a 32-bit value. Changing such statements to x = 255 ^ x
744gets rid of the warnings. There were also two missing casts in pcre2test.
745
746
747Version 10.32 10-September-2018
748-------------------------------
749
7501. When matching using the the REG_STARTEND feature of the POSIX API with a
751non-zero starting offset, unset capturing groups with lower numbers than a
752group that did capture something were not being correctly returned as "unset"
753(that is, with offset values of -1).
754
7552. When matching using the POSIX API, pcre2test used to omit listing unset
756groups altogether. Now it shows those that come before any actual captures as
757"<unset>", as happens for non-POSIX matching.
758
7593. Running "pcre2test -C" always stated "\R matches CR, LF, or CRLF only",
760whatever the build configuration was. It now correctly says "\R matches all
761Unicode newlines" in the default case when --enable-bsr-anycrlf has not been
762specified. Similarly, running "pcre2test -C bsr" never produced the result
763ANY.
764
7654. Matching the pattern /(*UTF)\C[^\v]+\x80/ against an 8-bit string containing
766multi-code-unit characters caused bad behaviour and possibly a crash. This
767issue was fixed for other kinds of repeat in release 10.20 by change 19, but
768repeating character classes were overlooked.
769
7705. pcre2grep now supports the inclusion of binary zeros in patterns that are
771read from files via the -f option.
772
7736. A small fix to pcre2grep to avoid compiler warnings for -Wformat-overflow=2.
774
7757. Added --enable-jit=auto support to configure.ac.
776
7778. Added some dummy variables to the heapframe structure in 16-bit and 32-bit
778modes for the benefit of m68k, where pointers can be 16-bit aligned. The
779dummies force 32-bit alignment and this ensures that the structure is a
780multiple of PCRE2_SIZE, a requirement that is tested at compile time. In other
781architectures, alignment requirements take care of this automatically.
782
7839. When returning an error from pcre2_pattern_convert(), ensure the error
784offset is set zero for early errors.
785
78610. A number of patches for Windows support from Daniel Richard G:
787
788 (a) List of error numbers in Runtest.bat corrected (it was not the same as in
789 Runtest).
790
791 (b) pcre2grep snprintf() workaround as used elsewhere in the tree.
792
793 (c) Support for non-C99 snprintf() that returns -1 in the overflow case.
794
79511. Minor tidy of pcre2_dfa_match() code.
796
79712. Refactored pcre2_dfa_match() so that the internal recursive calls no longer
798use the stack for local workspace and local ovectors. Instead, an initial block
799of stack is reserved, but if this is insufficient, heap memory is used. The
800heap limit parameter now applies to pcre2_dfa_match().
801
80213. If a "find limits" test of DFA matching in pcre2test resulted in too many
803matches for the ovector, no matches were displayed.
804
80514. Removed an occurrence of ctrl/Z from test 6 because Windows treats it as
806EOF. The test looks to have come from a fuzzer.
807
80815. If PCRE2 was built with a default match limit a lot greater than the
809default default of 10 000 000, some JIT tests of the match limit no longer
810failed. All such tests now set 10 000 000 as the upper limit.
811
81216. Another Windows related patch for pcregrep to ensure that WIN32 is
813undefined under Cygwin.
814
81517. Test for the presence of stdint.h and inttypes.h in configure and CMake and
816include whichever exists (stdint preferred) instead of unconditionally
817including stdint. This makes life easier for old and non-standard systems.
818
81918. Further changes to improve portability, especially to old and or non-
820standard systems:
821
822 (a) Put all printf arguments in RunGrepTest into single, not double, quotes,
823 and use \0 not \x00 for binary zero.
824
825 (b) Avoid the use of C++ (i.e. BCPL) // comments.
826
827 (c) Parameterize the use of %zu in pcre2test to make it like %td. For both of
828 these now, if using MSVC or a standard C before C99, %lu is used with a
829 cast if necessary.
830
83119. Applied a contributed patch to CMakeLists.txt to increase the stack size
832when linking pcre2test with MSVC. This gets rid of a stack overflow error in
833the standard set of tests.
834
83520. Output a warning in pcre2test when ignoring the "altglobal" modifier when
836it is given with the "replace" modifier.
837
83821. In both pcre2test and pcre2_substitute(), with global matching, a pattern
839that matched an empty string, but never at the starting match offset, was not
840handled in a Perl-compatible way. The pattern /(<?=\G.)/ is an example of such
841a pattern. Because \G is in a lookbehind assertion, there has to be a
842"bumpalong" before there can be a match. The automatic "advance by one
843character after an empty string match" rule is therefore inappropriate. A more
844complicated algorithm has now been implemented.
845
84622. When checking to see if a lookbehind is of fixed length, lookaheads were
847correctly ignored, but qualifiers on lookaheads were not being ignored, leading
848to an incorrect "lookbehind assertion is not fixed length" error.
849
85023. The VERSION condition test was reading fractional PCRE2 version numbers
851such as the 04 in 10.04 incorrectly and hence giving wrong results.
852
85324. Updated to Unicode version 11.0.0. As well as the usual addition of new
854scripts and characters, this involved re-jigging the grapheme break property
855algorithm because Unicode has changed the way emojis are handled.
856
85725. Fixed an obscure bug that struck when there were two atomic groups not
858separated by something with a backtracking point. There could be an incorrect
859backtrack into the first of the atomic groups. A complicated example is
860/(?>a(*:1))(?>b)(*SKIP:1)x|.*/ matched against "abc", where the *SKIP
861shouldn't find a MARK (because is in an atomic group), but it did.
862
86326. Upgraded the perltest.sh script: (1) #pattern lines can now be used to set
864a list of modifiers for all subsequent patterns - only those that the script
865recognizes are meaningful; (2) #subject lines can be used to set or unset a
866default "mark" modifier; (3) Unsupported #command lines give a warning when
867they are ignored; (4) Mark data is output only if the "mark" modifier is
868present.
869
87027. (*ACCEPT:ARG), (*FAIL:ARG), and (*COMMIT:ARG) are now supported.
871
87228. A (*MARK) name was not being passed back for positive assertions that were
873terminated by (*ACCEPT).
874
87529. Add support for \N{U+dddd}, but only in Unicode mode.
876
87730. Add support for (?^) for unsetting all imnsx options.
878
87931. The PCRE2_EXTENDED (/x) option only ever discarded space characters whose
880code point was less than 256 and that were recognized by the lookup table
881generated by pcre2_maketables(), which uses isspace() to identify white space.
882Now, when Unicode support is compiled, PCRE2_EXTENDED also discards U+0085,
883U+200E, U+200F, U+2028, and U+2029, which are additional characters defined by
884Unicode as "Pattern White Space". This makes PCRE2 compatible with Perl.
885
88632. In certain circumstances, option settings within patterns were not being
887correctly processed. For example, the pattern /((?i)A)(?m)B/ incorrectly
888matched "ab". (The (?m) setting lost the fact that (?i) should be reset at the
889end of its group during the parse process, but without another setting such as
890(?m) the compile phase got it right.) This bug was introduced by the
891refactoring in release 10.23.
892
89333. PCRE2 uses bcopy() if available when memmove() is not, and it used just to
894define memmove() as function call to bcopy(). This hasn't been tested for a
895long time because in pcre2test the result of memmove() was being used, whereas
896bcopy() doesn't return a result. This feature is now refactored always to call
897an emulation function when there is no memmove(). The emulation makes use of
898bcopy() when available.
899
90034. When serializing a pattern, set the memctl, executable_jit, and tables
901fields (that is, all the fields that contain pointers) to zeros so that the
902result of serializing is always the same. These fields are re-set when the
903pattern is deserialized.
904
90535. In a pattern such as /[^\x{100}-\x{ffff}]*[\x80-\xff]/ which has a repeated
906negative class with no characters less than 0x100 followed by a positive class
907with only characters less than 0x100, the first class was incorrectly being
908auto-possessified, causing incorrect match failures.
909
91036. Removed the character type bit ctype_meta, which dates from PCRE1 and is
911not used in PCRE2.
912
91337. Tidied up unnecessarily complicated macros used in the escapes table.
914
91538. Since 10.21, the new testoutput8-16-4 file has accidentally been omitted
916from distribution tarballs, owing to a typo in Makefile.am which had
917testoutput8-16-3 twice. Now fixed.
918
91939. If the only branch in a conditional subpattern was anchored, the whole
920subpattern was treated as anchored, when it should not have been, since the
921assumed empty second branch cannot be anchored. Demonstrated by test patterns
922such as /(?(1)^())b/ or /(?(?=^))b/.
923
92440. A repeated conditional subpattern that could match an empty string was
925always assumed to be unanchored. Now it it checked just like any other
926repeated conditional subpattern, and can be found to be anchored if the minimum
927quantifier is one or more. I can't see much use for a repeated anchored
928pattern, but the behaviour is now consistent.
929
93041. Minor addition to pcre2_jit_compile.c to avoid static analyzer complaint
931(for an event that could never occur but you had to have external information
932to know that).
933
93442. If before the first match in a file that was being searched by pcre2grep
935there was a line that was sufficiently long to cause the input buffer to be
936expanded, the variable holding the location of the end of the previous match
937was being adjusted incorrectly, and could cause an overflow warning from a code
938sanitizer. However, as the value is used only to print pending "after" lines
939when the next match is reached (and there are no such lines in this case) this
940bug could do no damage.
941
942
943Version 10.31 12-February-2018
944------------------------------
945
9461. Fix typo (missing ]) in VMS code in pcre2test.c.
947
9482. Replace the replicated code for matching extended Unicode grapheme sequences
949(which got a lot more complicated by change 10.30/49) by a single subroutine
950that is called by both pcre2_match() and pcre2_dfa_match().
951
9523. Add idempotent guard to pcre2_internal.h.
953
9544. Add new pcre2_config() options: PCRE2_CONFIG_NEVER_BACKSLASH_C and
955PCRE2_CONFIG_COMPILED_WIDTHS.
956
9575. Cut out \C tests in the JIT regression tests when NEVER_BACKSLASH_C is
958defined (e.g. by --enable-never-backslash-C).
959
9606. Defined public names for all the pcre2_compile() error numbers, and used
961the public names in pcre2_convert.c.
962
9637. Fixed a small memory leak in pcre2test (convert contexts).
964
9658. Added two casts to compile.c and one to match.c to avoid compiler warnings.
966
9679. Added code to pcre2grep when compiled under VMS to set the symbol
968PCRE2GREP_RC to the exit status, because VMS does not distinguish between
969exit(0) and exit(1).
970
97110. Added the -LM (list modifiers) option to pcre2test. Also made -C complain
972about a bad option only if the following argument item does not start with a
973hyphen.
974
97511. pcre2grep was truncating components of file names to 128 characters when
976processing files with the -r option, and also (some very odd code) truncating
977path names to 512 characters. There is now a check on the absolute length of
978full path file names, which may be up to 2047 characters long.
979
98012. When an assertion contained (*ACCEPT) it caused all open capturing groups
981to be closed (as for a non-assertion ACCEPT), which was wrong and could lead to
982misbehaviour for subsequent references to groups that started outside the
983assertion. ACCEPT in an assertion now closes only those groups that were
984started within that assertion. Fixes oss-fuzz issues 3852 and 3891.
985
98613. Multiline matching in pcre2grep was misbehaving if the pattern matched
987within a line, and then matched again at the end of the line and over into
988subsequent lines. Behaviour was different with and without colouring, and
989sometimes context lines were incorrectly printed and/or line endings were lost.
990All these issues should now be fixed.
991
99214. If --line-buffered was specified for pcre2grep when input was from a
993compressed file (.gz or .bz2) a segfault occurred. (Line buffering should be
994ignored for compressed files.)
995
99615. Although pcre2_jit_match checks whether the pattern is compiled
997in a given mode, it was also expected that at least one mode is available.
998This is fixed and pcre2_jit_match returns with PCRE2_ERROR_JIT_BADOPTION
999when the pattern is not optimized by JIT at all.
1000
100116. The line number and related variables such as match counts in pcre2grep
1002were all int variables, causing overflow when files with more than 2147483647
1003lines were processed (assuming 32-bit ints). They have all been changed to
1004unsigned long ints.
1005
100617. If a backreference with a minimum repeat count of zero was first in a
1007pattern, apart from assertions, an incorrect first matching character could be
1008recorded. For example, for the pattern /(?=(a))\1?b/, "b" was incorrectly set
1009as the first character of a match.
1010
101118. Characters in a leading positive assertion are considered for recording a
1012first character of a match when the rest of the pattern does not provide one.
1013However, a character in a non-assertive group within a leading assertion such
1014as in the pattern /(?=(a))\1?b/ caused this process to fail. This was an
1015infelicity rather than an outright bug, because it did not affect the result of
1016a match, just its speed. (In fact, in this case, the starting 'a' was
1017subsequently picked up in the study.)
1018
101919. A minor tidy in pcre2_match(): making all PCRE2_ERROR_ returns use "return"
1020instead of "RRETURN" saves unwinding the backtracks in these cases (only one
1021didn't).
1022
102320. Allocate a single callout block on the stack at the start of pcre2_match()
1024and set its never-changing fields once only. Do the same for pcre2_dfa_match().
1025
102621. Save the extra compile options (set in the compile context) with the
1027compiled pattern (they were not previously saved), add PCRE2_INFO_EXTRAOPTIONS
1028to retrieve them, and update pcre2test to show them.
1029
103022. Added PCRE2_CALLOUT_STARTMATCH and PCRE2_CALLOUT_BACKTRACK bits to a new
1031field callout_flags in callout blocks. The bits are set by pcre2_match(), but
1032not by JIT or pcre2_dfa_match(). Their settings are shown in pcre2test callouts
1033if the callout_extra subject modifier is set. These bits are provided to help
1034with tracking how a backtracking match is proceeding.
1035
103623. Updated the pcre2demo.c demonstration program, which was missing the extra
1037code for -g that handles the case when \K in an assertion causes the match to
1038end at the original start point. Also arranged for it to detect when \K causes
1039the end of a match to be before its start.
1040
104124. Similar to 23 above, strange things (including loops) could happen in
1042pcre2grep when \K was used in an assertion when --colour was used or in
1043multiline mode. The "end at original start point" bug is fixed, and if the end
1044point is found to be before the start point, they are swapped.
1045
104625. When PCRE2_FIRSTLINE without PCRE2_NO_START_OPTIMIZE was used in non-JIT
1047matching (both pcre2_match() and pcre2_dfa_match()) and the matched string
1048started with the first code unit of a newline sequence, matching failed because
1049it was not tried at the newline.
1050
105126. Code for giving up a non-partial match after failing to find a starting
1052code unit anywhere in the subject was missing when searching for one of a
1053number of code units (the bitmap case) in both pcre2_match() and
1054pcre2_dfa_match(). This was a missing optimization rather than a bug.
1055
105627. Tidied up the ACROSSCHAR macro to be like FORWARDCHAR and BACKCHAR, using a
1057pointer argument rather than a code unit value. This should not have affected
1058the generated code.
1059
106028. The JIT compiler has been updated.
1061
106229. Avoid pointer overflow for unset captures in pcre2_substring_list_get().
1063This could not actually cause a crash because it was always used in a memcpy()
1064call with zero length.
1065
106630. Some internal structures have a variable-length ovector[] as their last
1067element. Their actual memory is obtained dynamically, giving an ovector of
1068appropriate length. However, they are defined in the structure as
1069ovector[NUMBER], where NUMBER is large so that array bound checkers don't
1070grumble. The value of NUMBER was 10000, but a fuzzer exceeded 5000 capturing
1071groups, making the ovector larger than this. The number has been increased to
1072131072, which allows for the maximum number of captures (65535) plus the
1073overall match. This fixes oss-fuzz issue 5415.
1074
107531. Auto-possessification at the end of a capturing group was dependent on what
1076follows the group (e.g. /(a+)b/ would auto-possessify the a+) but this caused
1077incorrect behaviour when the group was called recursively from elsewhere in the
1078pattern where something different might follow. This bug is an unforseen
1079consequence of change #1 for 10.30 - the implementation of backtracking into
1080recursions. Iterators at the ends of capturing groups are no longer considered
1081for auto-possessification if the pattern contains any recursions. Fixes
1082Bugzilla #2232.
1083
1084
1085Version 10.30 14-August-2017
1086----------------------------
1087
10881. The main interpreter, pcre2_match(), has been refactored into a new version
1089that does not use recursive function calls (and therefore the stack) for
1090remembering backtracking positions. This makes --disable-stack-for-recursion a
1091NOOP. The new implementation allows backtracking into recursive group calls in
1092patterns, making it more compatible with Perl, and also fixes some other
1093hard-to-do issues such as #1887 in Bugzilla. The code is also cleaner because
1094the old code had a number of fudges to try to reduce stack usage. It seems to
1095run no slower than the old code.
1096
1097A number of bugs in the refactored code were subsequently fixed during testing
1098before release, but after the code was made available in the repository. These
1099bugs were never in fully released code, but are noted here for the record.
1100
1101 (a) If a pattern had fewer capturing parentheses than the ovector supplied in
1102 the match data block, a memory error (detectable by ASAN) occurred after
1103 a match, because the external block was being set from non-existent
1104 internal ovector fields. Fixes oss-fuzz issue 781.
1105
1106 (b) A pattern with very many capturing parentheses (when the internal frame
1107 size was greater than the initial frame vector on the stack) caused a
1108 crash. A vector on the heap is now set up at the start of matching if the
1109 vector on the stack is not big enough to handle at least 10 frames.
1110 Fixes oss-fuzz issue 783.
1111
1112 (c) Handling of (*VERB)s in recursions was wrong in some cases.
1113
1114 (d) Captures in negative assertions that were used as conditions were not
1115 happening if the assertion matched via (*ACCEPT).
1116
1117 (e) Mark values were not being passed out of recursions.
1118
1119 (f) Refactor some code in do_callout() to avoid picky compiler warnings about
1120 negative indices. Fixes oss-fuzz issue 1454.
1121
1122 (g) Similarly refactor the way the variable length ovector is addressed for
1123 similar reasons. Fixes oss-fuzz issue 1465.
1124
11252. Now that pcre2_match() no longer uses recursive function calls (see above),
1126the "match limit recursion" value seems misnamed. It still exists, and limits
1127the depth of tree that is searched. To avoid future confusion, it has been
1128renamed as "depth limit" in all relevant places (--with-depth-limit,
1129(*LIMIT_DEPTH), pcre2_set_depth_limit(), etc) but the old names are still
1130available for backwards compatibility.
1131
11323. Hardened pcre2test so as to reduce the number of bugs reported by fuzzers:
1133
1134 (a) Check for malloc failures when getting memory for the ovector (POSIX) or
1135 the match data block (non-POSIX).
1136
11374. In the 32-bit library in non-UTF mode, an attempt to find a Unicode property
1138for a character with a code point greater than 0x10ffff (the Unicode maximum)
1139caused a crash.
1140
11415. If a lookbehind assertion that contained a back reference to a group
1142appearing later in the pattern was compiled with the PCRE2_ANCHORED option,
1143undefined actions (often a segmentation fault) could occur, depending on what
1144other options were set. An example assertion is (?<!\1(abc)) where the
1145reference \1 precedes the group (abc). This fixes oss-fuzz issue 865.
1146
11476. Added the PCRE2_INFO_FRAMESIZE item to pcre2_pattern_info() and arranged for
1148pcre2test to use it to output the frame size when the "framesize" modifier is
1149given.
1150
11517. Reworked the recursive pattern matching in the JIT compiler to follow the
1152interpreter changes.
1153
11548. When the zero_terminate modifier was specified on a pcre2test subject line
1155for global matching, unpredictable things could happen. For example, in UTF-8
1156mode, the pattern //g,zero_terminate read random memory when matched against an
1157empty string with zero_terminate. This was a bug in pcre2test, not the library.
1158
11599. Moved some Windows-specific code in pcre2grep (introduced in 10.23/13) out
1160of the section that is compiled when Unix-style directory scanning is
1161available, and into a new section that is always compiled for Windows.
1162
116310. In pcre2test, explicitly close the file after an error during serialization
1164or deserialization (the "load" or "save" commands).
1165
116611. Fix memory leak in pcre2_serialize_decode() when the input is invalid.
1167
116812. Fix potential NULL dereference in pcre2_callout_enumerate() if called with
1169a NULL pattern pointer when Unicode support is available.
1170
117113. When the 32-bit library was being tested by pcre2test, error messages that
1172were longer than 64 code units could cause a buffer overflow. This was a bug in
1173pcre2test.
1174
117514. The alternative matching function, pcre2_dfa_match() misbehaved if it
1176encountered a character class with a possessive repeat, for example [a-f]{3}+.
1177
117815. The depth (formerly recursion) limit now applies to DFA matching (as
1179of 10.23/36); pcre2test has been upgraded so that \=find_limits works with DFA
1180matching to find the minimum value for this limit.
1181
118216. Since 10.21, if pcre2_match() was called with a null context, default
1183memory allocation functions were used instead of whatever was used when the
1184pattern was compiled.
1185
118617. Changes to the pcre2test "memory" modifier on a subject line. These apply
1187only to pcre2_match():
1188
1189 (a) Warn if null_context is set on both pattern and subject, because the
1190 memory details cannot then be shown.
1191
1192 (b) Remember (up to a certain number of) memory allocations and their
1193 lengths, and list only the lengths, so as to be system-independent.
1194 (In practice, the new interpreter never has more than 2 blocks allocated
1195 simultaneously.)
1196
119718. Make pcre2test detect an error return from pcre2_get_error_message(), give
1198a message, and abandon the run (this would have detected #13 above).
1199
120019. Implemented PCRE2_ENDANCHORED.
1201
120220. Applied Jason Hood's patches (slightly modified) to pcre2grep, to implement
1203the --output=text (-O) option and the inbuilt callout echo.
1204
120521. Extend auto-anchoring etc. to ignore groups with a zero qualifier and
1206single-branch conditions with a false condition (e.g. DEFINE) at the start of a
1207branch. For example, /(?(DEFINE)...)^A/ and /(...){0}^B/ are now flagged as
1208anchored.
1209
121022. Added an explicit limit on the amount of heap used by pcre2_match(), set by
1211pcre2_set_heap_limit() or (*LIMIT_HEAP=xxx). Upgraded pcre2test to show the
1212heap limit along with other pattern information, and to find the minimum when
1213the find_limits modifier is set.
1214
121523. Write to the last 8 bytes of the pcre2_real_code structure when a compiled
1216pattern is set up so as to initialize any padding the compiler might have
1217included. This avoids valgrind warnings when a compiled pattern is copied, in
1218particular when it is serialized.
1219
122024. Remove a redundant line of code left in accidentally a long time ago.
1221
122225. Remove a duplication typo in pcre2_tables.c
1223
122426. Correct an incorrect cast in pcre2_valid_utf.c
1225
122627. Update pcre2test, remove some unused code in pcre2_match(), and upgrade the
1227tests to improve coverage.
1228
122928. Some fixes/tidies as a result of looking at Coverity Scan output:
1230
1231 (a) Typo: ">" should be ">=" in opcode check in pcre2_auto_possess.c.
1232 (b) Added some casts to avoid "suspicious implicit sign extension".
1233 (c) Resource leaks in pcre2test in rare error cases.
1234 (d) Avoid warning for never-use case OP_TABLE_LENGTH which is just a fudge
1235 for checking at compile time that tables are the right size.
1236 (e) Add missing "fall through" comment.
1237
123829. Implemented PCRE2_EXTENDED_MORE and related /xx and (?xx) features.
1239
124030. Implement (?n: for PCRE2_NO_AUTO_CAPTURE, because Perl now has this.
1241
124231. If more than one of "push", "pushcopy", or "pushtablescopy" were set in
1243pcre2test, a crash could occur.
1244
124532. Make -bigstack in RunTest allocate a 64MiB stack (instead of 16MiB) so
1246that all the tests can run with clang's sanitizing options.
1247
124833. Implement extra compile options in the compile context and add the first
1249one: PCRE2_EXTRA_ALLOW_SURROGATE_ESCAPES.
1250
125134. Implement newline type PCRE2_NEWLINE_NUL.
1252
125335. A lookbehind assertion that had a zero-length branch caused undefined
1254behaviour when processed by pcre2_dfa_match(). This is oss-fuzz issue 1859.
1255
125636. The match limit value now also applies to pcre2_dfa_match() as there are
1257patterns that can use up a lot of resources without necessarily recursing very
1258deeply. (Compare item 10.23/36.) This should fix oss-fuzz #1761.
1259
126037. Implement PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL.
1261
126238. Fix returned offsets from regexec() when REG_STARTEND is used with a
1263starting offset greater than zero.
1264
126539. Implement REG_PEND (GNU extension) for the POSIX wrapper.
1266
126740. Implement the subject_literal modifier in pcre2test, and allow jitstack on
1268pattern lines.
1269
127041. Implement PCRE2_LITERAL and use it to support REG_NOSPEC.
1271
127242. Implement PCRE2_EXTRA_MATCH_LINE and PCRE2_EXTRA_MATCH_WORD for the benefit
1273of pcre2grep.
1274
127543. Re-implement pcre2grep's -F, -w, and -x options using PCRE2_LITERAL,
1276PCRE2_EXTRA_MATCH_WORD, and PCRE2_EXTRA_MATCH_LINE. This fixes two bugs:
1277
1278 (a) The -F option did not work for fixed strings containing \E.
1279 (b) The -w option did not work for patterns with multiple branches.
1280
128144. Added configuration options for the SELinux compatible execmem allocator in
1282JIT.
1283
128445. Increased the limit for searching for a "must be present" code unit in
1285subjects from 1000 to 2000 for 8-bit searches, since they use memchr() and are
1286much faster.
1287
128846. Arrange for anchored patterns to record and use "first code unit" data,
1289because this can give a fast "no match" without searching for a "required code
1290unit". Previously only non-anchored patterns did this.
1291
129247. Upgraded the Unicode tables from Unicode 8.0.0 to Unicode 10.0.0.
1293
129448. Add the callout_no_where modifier to pcre2test.
1295
129649. Update extended grapheme breaking rules to the latest set that are in
1297Unicode Standard Annex #29.
1298
129950. Added experimental foreign pattern conversion facilities
1300(pcre2_pattern_convert() and friends).
1301
130251. Change the macro FWRITE, used in pcre2grep, to FWRITE_IGNORE because FWRITE
1303is defined in a system header in cygwin. Also modified some of the #ifdefs in
1304pcre2grep related to Windows and Cygwin support.
1305
130652. Change 3(g) for 10.23 was a bit too zealous. If a hyphen that follows a
1307character class is the last character in the class, Perl does not give a
1308warning. PCRE2 now also treats this as a literal.
1309
131053. Related to 52, though PCRE2 was throwing an error for [[:digit:]-X] it was
1311not doing so for [\d-X] (and similar escapes), as is documented.
1312
131354. Fixed a MIPS issue in the JIT compiler reported by Joshua Kinard.
1314
131555. Fixed a "maybe uninitialized" warning for class_uchardata in \p handling in
1316pcre2_compile() which could never actually trigger (code should have been cut
1317out when Unicode support is disabled).
1318
1319
1320Version 10.23 14-February-2017
1321------------------------------
1322
13231. Extended pcre2test with the utf8_input modifier so that it is able to
1324generate all possible 16-bit and 32-bit code unit values in non-UTF modes.
1325
13262. In any wide-character mode (8-bit UTF or any 16-bit or 32-bit mode), without
1327PCRE2_UCP set, a negative character type such as \D in a positive class should
1328cause all characters greater than 255 to match, whatever else is in the class.
1329There was a bug that caused this not to happen if a Unicode property item was
1330added to such a class, for example [\D\P{Nd}] or [\W\pL].
1331
13323. There has been a major re-factoring of the pcre2_compile.c file. Most syntax
1333checking is now done in the pre-pass that identifies capturing groups. This has
1334reduced the amount of duplication and made the code tidier. While doing this,
1335some minor bugs and Perl incompatibilities were fixed, including:
1336
1337 (a) \Q\E in the middle of a quantifier such as A+\Q\E+ is now ignored instead
1338 of giving an invalid quantifier error.
1339
1340 (b) {0} can now be used after a group in a lookbehind assertion; previously
1341 this caused an "assertion is not fixed length" error.
1342
1343 (c) Perl always treats (?(DEFINE) as a "define" group, even if a group with
1344 the name "DEFINE" exists. PCRE2 now does likewise.
1345
1346 (d) A recursion condition test such as (?(R2)...) must now refer to an
1347 existing subpattern.
1348
1349 (e) A conditional recursion test such as (?(R)...) misbehaved if there was a
1350 group whose name began with "R".
1351
1352 (f) When testing zero-terminated patterns under valgrind, the terminating
1353 zero is now marked "no access". This catches bugs that would otherwise
1354 show up only with non-zero-terminated patterns.
1355
1356 (g) A hyphen appearing immediately after a POSIX character class (for example
1357 /[[:ascii:]-z]/) now generates an error. Perl does accept this as a
1358 literal, but gives a warning, so it seems best to fail it in PCRE.
1359
1360 (h) An empty \Q\E sequence may appear after a callout that precedes an
1361 assertion condition (it is, of course, ignored).
1362
1363One effect of the refactoring is that some error numbers and messages have
1364changed, and the pattern offset given for compiling errors is not always the
1365right-most character that has been read. In particular, for a variable-length
1366lookbehind assertion it now points to the start of the assertion. Another
1367change is that when a callout appears before a group, the "length of next
1368pattern item" that is passed now just gives the length of the opening
1369parenthesis item, not the length of the whole group. A length of zero is now
1370given only for a callout at the end of the pattern. Automatic callouts are no
1371longer inserted before and after explicit callouts in the pattern.
1372
1373A number of bugs in the refactored code were subsequently fixed during testing
1374before release, but after the code was made available in the repository. Many
1375of the bugs were discovered by fuzzing testing. Several of them were related to
1376the change from assuming a zero-terminated pattern (which previously had
1377required non-zero terminated strings to be copied). These bugs were never in
1378fully released code, but are noted here for the record.
1379
1380 (a) An overall recursion such as (?0) inside a lookbehind assertion was not
1381 being diagnosed as an error.
1382
1383 (b) In utf mode, the length of a *MARK (or other verb) name was being checked
1384 in characters instead of code units, which could lead to bad code being
1385 compiled, leading to unpredictable behaviour.
1386
1387 (c) In extended /x mode, characters whose code was greater than 255 caused
1388 a lookup outside one of the global tables. A similar bug existed for wide
1389 characters in *VERB names.
1390
1391 (d) The amount of memory needed for a compiled pattern was miscalculated if a
1392 lookbehind contained more than one toplevel branch and the first branch
1393 was of length zero.
1394
1395 (e) In UTF-8 or UTF-16 modes with PCRE2_EXTENDED (/x) set and a non-zero-
1396 terminated pattern, if a # comment ran on to the end of the pattern, one
1397 or more code units past the end were being read.
1398
1399 (f) An unterminated repeat at the end of a non-zero-terminated pattern (e.g.
1400 "{2,2") could cause reading beyond the pattern.
1401
1402 (g) When reading a callout string, if the end delimiter was at the end of the
1403 pattern one further code unit was read.
1404
1405 (h) An unterminated number after \g' could cause reading beyond the pattern.
1406
1407 (i) An insufficient memory size was being computed for compiling with
1408 PCRE2_AUTO_CALLOUT.
1409
1410 (j) A conditional group with an assertion condition used more memory than was
1411 allowed for it during parsing, so too many of them could therefore
1412 overrun a buffer.
1413
1414 (k) If parsing a pattern exactly filled the buffer, the internal test for
1415 overrun did not check when the final META_END item was added.
1416
1417 (l) If a lookbehind contained a subroutine call, and the called group
1418 contained an option setting such as (?s), and the PCRE2_ANCHORED option
1419 was set, unpredictable behaviour could occur. The underlying bug was
1420 incorrect code and insufficient checking while searching for the end of
1421 the called subroutine in the parsed pattern.
1422
1423 (m) Quantifiers following (*VERB)s were not being diagnosed as errors.
1424
1425 (n) The use of \Q...\E in a (*VERB) name when PCRE2_ALT_VERBNAMES and
1426 PCRE2_AUTO_CALLOUT were both specified caused undetermined behaviour.
1427
1428 (o) If \Q was preceded by a quantified item, and the following \E was
1429 followed by '?' or '+', and there was at least one literal character
1430 between them, an internal error "unexpected repeat" occurred (example:
1431 /.+\QX\E+/).
1432
1433 (p) A buffer overflow could occur while sorting the names in the group name
1434 list (depending on the order in which the names were seen).
1435
1436 (q) A conditional group that started with a callout was not doing the right
1437 check for a following assertion, leading to compiling bad code. Example:
1438 /(?(C'XX))?!XX/
1439
1440 (r) If a character whose code point was greater than 0xffff appeared within
1441 a lookbehind that was within another lookbehind, the calculation of the
1442 lookbehind length went wrong and could provoke an internal error.
1443
1444 (t) The sequence \E- or \Q\E- after a POSIX class in a character class caused
1445 an internal error. Now the hyphen is treated as a literal.
1446
14474. Back references are now permitted in lookbehind assertions when there are
1448no duplicated group numbers (that is, (?| has not been used), and, if the
1449reference is by name, there is only one group of that name. The referenced
1450group must, of course be of fixed length.
1451
14525. pcre2test has been upgraded so that, when run under valgrind with valgrind
1453support enabled, reading past the end of the pattern is detected, both when
1454compiling and during callout processing.
1455
14566. \g{+<number>} (e.g. \g{+2} ) is now supported. It is a "forward back
1457reference" and can be useful in repetitions (compare \g{-<number>} ). Perl does
1458not recognize this syntax.
1459
14607. Automatic callouts are no longer generated before and after callouts in the
1461pattern.
1462
14638. When pcre2test was outputing information from a callout, the caret indicator
1464for the current position in the subject line was incorrect if it was after an
1465escape sequence for a character whose code point was greater than \x{ff}.
1466
14679. Change 19 for 10.22 had a typo (PCRE_STATIC_RUNTIME should be
1468PCRE2_STATIC_RUNTIME). Fix from David Gaussmann.
1469
147010. Added --max-buffer-size to pcre2grep, to allow for automatic buffer
1471expansion when long lines are encountered. Original patch by Dmitry
1472Cherniachenko.
1473
147411. If pcre2grep was compiled with JIT support, but the library was compiled
1475without it (something that neither ./configure nor CMake allow, but it can be
1476done by editing config.h), pcre2grep was giving a JIT error. Now it detects
1477this situation and does not try to use JIT.
1478
147912. Added some "const" qualifiers to variables in pcre2grep.
1480
148113. Added Dmitry Cherniachenko's patch for colouring output in Windows
1482(untested by me). Also, look for GREP_COLOUR or GREP_COLOR if the environment
1483variables PCRE2GREP_COLOUR and PCRE2GREP_COLOR are not found.
1484
148514. Add the -t (grand total) option to pcre2grep.
1486
148715. A number of bugs have been mended relating to match start-up optimizations
1488when the first thing in a pattern is a positive lookahead. These all applied
1489only when PCRE2_NO_START_OPTIMIZE was *not* set:
1490
1491 (a) A pattern such as (?=.*X)X$ was incorrectly optimized as if it needed
1492 both an initial 'X' and a following 'X'.
1493 (b) Some patterns starting with an assertion that started with .* were
1494 incorrectly optimized as having to match at the start of the subject or
1495 after a newline. There are cases where this is not true, for example,
1496 (?=.*[A-Z])(?=.{8,16})(?!.*[\s]) matches after the start in lines that
1497 start with spaces. Starting .* in an assertion is no longer taken as an
1498 indication of matching at the start (or after a newline).
1499
150016. The "offset" modifier in pcre2test was not being ignored (as documented)
1501when the POSIX API was in use.
1502
150317. Added --enable-fuzz-support to "configure", causing an non-installed
1504library containing a test function that can be called by fuzzers to be
1505compiled. A non-installed binary to run the test function locally, called
1506pcre2fuzzcheck is also compiled.
1507
150818. A pattern with PCRE2_DOTALL (/s) set but not PCRE2_NO_DOTSTAR_ANCHOR, and
1509which started with .* inside a positive lookahead was incorrectly being
1510compiled as implicitly anchored.
1511
151219. Removed all instances of "register" declarations, as they are considered
1513obsolete these days and in any case had become very haphazard.
1514
151520. Add strerror() to pcre2test for failed file opening.
1516
151721. Make pcre2test -C list valgrind support when it is enabled.
1518
151922. Add the use_length modifier to pcre2test.
1520
152123. Fix an off-by-one bug in pcre2test for the list of names for 'get' and
1522'copy' modifiers.
1523
152424. Add PCRE2_CALL_CONVENTION into the prototype declarations in pcre2.h as it
1525is apparently needed there as well as in the function definitions. (Why did
1526nobody ask for this in PCRE1?)
1527
152825. Change the _PCRE2_H and _PCRE2_UCP_H guard macros in the header files to
1529PCRE2_H_IDEMPOTENT_GUARD and PCRE2_UCP_H_IDEMPOTENT_GUARD to be more standard
1530compliant and unique.
1531
153226. pcre2-config --libs-posix was listing -lpcre2posix instead of
1533-lpcre2-posix. Also, the CMake build process was building the library with the
1534wrong name.
1535
153627. In pcre2test, give some offset information for errors in hex patterns.
1537This uses the C99 formatting sequence %td, except for MSVC which doesn't
1538support it - %lu is used instead.
1539
154028. Implemented pcre2_code_copy_with_tables(), and added pushtablescopy to
1541pcre2test for testing it.
1542
154329. Fix small memory leak in pcre2test.
1544
154530. Fix out-of-bounds read for partial matching of /./ against an empty string
1546when the newline type is CRLF.
1547
154831. Fix a bug in pcre2test that caused a crash when a locale was set either in
1549the current pattern or a previous one and a wide character was matched.
1550
155132. The appearance of \p, \P, or \X in a substitution string when
1552PCRE2_SUBSTITUTE_EXTENDED was set caused a segmentation fault (NULL
1553dereference).
1554
155533. If the starting offset was specified as greater than the subject length in
1556a call to pcre2_substitute() an out-of-bounds memory reference could occur.
1557
155834. When PCRE2 was compiled to use the heap instead of the stack for recursive
1559calls to match(), a repeated minimizing caseless back reference, or a
1560maximizing one where the two cases had different numbers of code units,
1561followed by a caseful back reference, could lose the caselessness of the first
1562repeated back reference (example: /(Z)(a)\2{1,2}?(?-i)\1X/i should match ZaAAZX
1563but didn't).
1564
156535. When a pattern is too complicated, PCRE2 gives up trying to find a minimum
1566matching length and just records zero. Typically this happens when there are
1567too many nested or recursive back references. If the limit was reached in
1568certain recursive cases it failed to be triggered and an internal error could
1569be the result.
1570
157136. The pcre2_dfa_match() function now takes note of the recursion limit for
1572the internal recursive calls that are used for lookrounds and recursions within
1573the pattern.
1574
157537. More refactoring has got rid of the internal could_be_empty_branch()
1576function (around 400 lines of code, including comments) by keeping track of
1577could-be-emptiness as the pattern is compiled instead of scanning compiled
1578groups. (This would have been much harder before the refactoring of #3 above.)
1579This lifts a restriction on the number of branches in a group (more than about
15801100 would give "pattern is too complicated").
1581
158238. Add the "-ac" command line option to pcre2test as a synonym for "-pattern
1583auto_callout".
1584
158539. In a library with Unicode support, incorrect data was compiled for a
1586pattern with PCRE2_UCP set without PCRE2_UTF if a class required all wide
1587characters to match (for example, /[\s[:^ascii:]]/).
1588
158940. The callout_error modifier has been added to pcre2test to make it possible
1590to return PCRE2_ERROR_CALLOUT from a callout.
1591
159241. A minor change to pcre2grep: colour reset is now "<esc>[0m" instead of
1593"<esc>[00m".
1594
159542. The limit in the auto-possessification code that was intended to catch
1596overly-complicated patterns and not spend too much time auto-possessifying was
1597being reset too often, resulting in very long compile times for some patterns.
1598Now such patterns are no longer completely auto-possessified.
1599
160043. Applied Jason Hood's revised patch for RunTest.bat.
1601
160244. Added a new Windows script RunGrepTest.bat, courtesy of Jason Hood.
1603
160445. Minor cosmetic fix to pcre2test: move a variable that is not used under
1605Windows into the "not Windows" code.
1606
160746. Applied Jason Hood's patches to upgrade pcre2grep under Windows and tidy
1608some of the code:
1609
1610 * normalised the Windows condition by ensuring WIN32 is defined;
1611 * enables the callout feature under Windows;
1612 * adds globbing (Microsoft's implementation expands quoted args),
1613 using a tweaked opendirectory;
1614 * implements the is_*_tty functions for Windows;
1615 * --color=always will write the ANSI sequences to file;
1616 * add sequences 4 (underline works on Win10) and 5 (blink as bright
1617 background, relatively standard on DOS/Win);
1618 * remove the (char *) casts for the now-const strings;
1619 * remove GREP_COLOUR (grep's command line allowed the 'u', but not
1620 the environment), parsing GREP_COLORS instead;
1621 * uses the current colour if not set, rather than black;
1622 * add print_match for the undefined case;
1623 * fixes a typo.
1624
1625In addition, colour settings containing anything other than digits and
1626semicolon are ignored, and the colour controls are no longer output for empty
1627strings.
1628
162947. Detecting patterns that are too large inside the length-measuring loop
1630saves processing ridiculously long patterns to their end.
1631
163248. Ignore PCRE2_CASELESS when processing \h, \H, \v, and \V in classes as it
1633just wastes time. In the UTF case it can also produce redundant entries in
1634XCLASS lists caused by characters with multiple other cases and pairs of
1635characters in the same "not-x" sublists.
1636
163749. A pattern such as /(?=(a\K))/ can report the end of the match being before
1638its start; pcre2test was not handling this correctly when using the POSIX
1639interface (it was OK with the native interface).
1640
164150. In pcre2grep, ignore all JIT compile errors. This means that pcre2grep will
1642continue to work, falling back to interpretation if anything goes wrong with
1643JIT.
1644
164551. Applied patches from Christian Persch to configure.ac to make use of the
1646AC_USE_SYSTEM_EXTENSIONS macro and to test for functions used by the JIT
1647modules.
1648
164952. Minor fixes to pcre2grep from Jason Hood:
1650 * fixed some spacing;
1651 * Windows doesn't usually use single quotes, so I've added a define
1652 to use appropriate quotes [in an example];
1653 * LC_ALL was displayed as "LCC_ALL";
1654 * numbers 11, 12 & 13 should end in "th";
1655 * use double quotes in usage message.
1656
165753. When autopossessifying, skip empty branches without recursion, to reduce
1658stack usage for the benefit of clang with -fsanitize-address, which uses huge
1659stack frames. Example pattern: /X?(R||){3335}/. Fixes oss-fuzz issue 553.
1660
166154. A pattern with very many explicit back references to a group that is a long
1662way from the start of the pattern could take a long time to compile because
1663searching for the referenced group in order to find the minimum length was
1664being done repeatedly. Now up to 128 group minimum lengths are cached and the
1665attempt to find a minimum length is abandoned if there is a back reference to a
1666group whose number is greater than 128. (In that case, the pattern is so
1667complicated that this optimization probably isn't worth it.) This fixes
1668oss-fuzz issue 557.
1669
167055. Issue 32 for 10.22 below was not correctly fixed. If pcre2grep in multiline
1671mode with --only-matching matched several lines, it restarted scanning at the
1672next line instead of moving on to the end of the matched string, which can be
1673several lines after the start.
1674
167556. Applied Jason Hood's new patch for RunGrepTest.bat that updates it in line
1676with updates to the non-Windows version.
1677
1678
1679
1680Version 10.22 29-July-2016
1681--------------------------
1682
16831. Applied Jason Hood's patches to RunTest.bat and testdata/wintestoutput3
1684to fix problems with running the tests under Windows.
1685
16862. Implemented a facility for quoting literal characters within hexadecimal
1687patterns in pcre2test, to make it easier to create patterns with just a few
1688non-printing characters.
1689
16903. Binary zeros are not supported in pcre2test input files. It now detects them
1691and gives an error.
1692
16934. Updated the valgrind parameters in RunTest: (a) changed smc-check=all to
1694smc-check=all-non-file; (b) changed obj:* in the suppression file to obj:??? so
1695that it matches only unknown objects.
1696
16975. Updated the maintenance script maint/ManyConfigTests to make it easier to
1698select individual groups of tests.
1699
17006. When the POSIX wrapper function regcomp() is called, the REG_NOSUB option
1701used to set PCRE2_NO_AUTO_CAPTURE when calling pcre2_compile(). However, this
1702disables the use of back references (and subroutine calls), which are supported
1703by other implementations of regcomp() with RE_NOSUB. Therefore, REG_NOSUB no
1704longer causes PCRE2_NO_AUTO_CAPTURE to be set, though it still ignores nmatch
1705and pmatch when regexec() is called.
1706
17077. Because of 6 above, pcre2test has been modified with a new modifier called
1708posix_nosub, to call regcomp() with REG_NOSUB. Previously the no_auto_capture
1709modifier had this effect. That option is now ignored when the POSIX API is in
1710use.
1711
17128. Minor tidies to the pcre2demo.c sample program, including more comments
1713about its 8-bit-ness.
1714
17159. Detect unmatched closing parentheses and give the error in the pre-scan
1716instead of later. Previously the pre-scan carried on and could give a
1717misleading incorrect error message. For example, /(?J)(?'a'))(?'a')/ gave a
1718message about invalid duplicate group names.
1719
172010. It has happened that pcre2test was accidentally linked with another POSIX
1721regex library instead of libpcre2-posix. In this situation, a call to regcomp()
1722(in the other library) may succeed, returning zero, but of course putting its
1723own data into the regex_t block. In one example the re_pcre2_code field was
1724left as NULL, which made pcre2test think it had not got a compiled POSIX regex,
1725so it treated the next line as another pattern line, resulting in a confusing
1726error message. A check has been added to pcre2test to see if the data returned
1727from a successful call of regcomp() are valid for PCRE2's regcomp(). If they
1728are not, an error message is output and the pcre2test run is abandoned. The
1729message points out the possibility of a mis-linking. Hopefully this will avoid
1730some head-scratching the next time this happens.
1731
173211. A pattern such as /(?<=((?C)0))/, which has a callout inside a lookbehind
1733assertion, caused pcre2test to output a very large number of spaces when the
1734callout was taken, making the program appearing to loop.
1735
173612. A pattern that included (*ACCEPT) in the middle of a sufficiently deeply
1737nested set of parentheses of sufficient size caused an overflow of the
1738compiling workspace (which was diagnosed, but of course is not desirable).
1739
174013. Detect missing closing parentheses during the pre-pass for group
1741identification.
1742
174314. Changed some integer variable types and put in a number of casts, following
1744a report of compiler warnings from Visual Studio 2013 and a few tests with
1745gcc's -Wconversion (which still throws up a lot).
1746
174715. Implemented pcre2_code_copy(), and added pushcopy and #popcopy to pcre2test
1748for testing it.
1749
175016. Change 66 for 10.21 introduced the use of snprintf() in PCRE2's version of
1751regerror(). When the error buffer is too small, my version of snprintf() puts a
1752binary zero in the final byte. Bug #1801 seems to show that other versions do
1753not do this, leading to bad output from pcre2test when it was checking for
1754buffer overflow. It no longer assumes a binary zero at the end of a too-small
1755regerror() buffer.
1756
175717. Fixed typo ("&&" for "&") in pcre2_study(). Fortunately, this could not
1758actually affect anything, by sheer luck.
1759
176018. Two minor fixes for MSVC compilation: (a) removal of apparently incorrect
1761"const" qualifiers in pcre2test and (b) defining snprintf as _snprintf for
1762older MSVC compilers. This has been done both in src/pcre2_internal.h for most
1763of the library, and also in src/pcre2posix.c, which no longer includes
1764pcre2_internal.h (see 24 below).
1765
176619. Applied Chris Wilson's patch (Bugzilla #1681) to CMakeLists.txt for MSVC
1767static compilation. Subsequently applied Chris Wilson's second patch, putting
1768the first patch under a new option instead of being unconditional when
1769PCRE_STATIC is set.
1770
177120. Updated pcre2grep to set stdout as binary when run under Windows, so as not
1772to convert \r\n at the ends of reflected lines into \r\r\n. This required
1773ensuring that other output that is written to stdout (e.g. file names) uses the
1774appropriate line terminator: \r\n for Windows, \n otherwise.
1775
177621. When a line is too long for pcre2grep's internal buffer, show the maximum
1777length in the error message.
1778
177922. Added support for string callouts to pcre2grep (Zoltan's patch with PH
1780additions).
1781
178223. RunTest.bat was missing a "set type" line for test 22.
1783
178424. The pcre2posix.c file was including pcre2_internal.h, and using some
1785"private" knowledge of the data structures. This is unnecessary; the code has
1786been re-factored and no longer includes pcre2_internal.h.
1787
178825. A racing condition is fixed in JIT reported by Mozilla.
1789
179026. Minor code refactor to avoid "array subscript is below array bounds"
1791compiler warning.
1792
179327. Minor code refactor to avoid "left shift of negative number" warning.
1794
179528. Add a bit more sanity checking to pcre2_serialize_decode() and document
1796that it expects trusted data.
1797
179829. Fix typo in pcre2_jit_test.c
1799
180030. Due to an oversight, pcre2grep was not making use of JIT when available.
1801This is now fixed.
1802
180331. The RunGrepTest script is updated to use the valgrind suppressions file
1804when testing with JIT under valgrind (compare 10.21/51 below). The suppressions
1805file is updated so that is now the same as for PCRE1: it suppresses the
1806Memcheck warnings Addr16 and Cond in unknown objects (that is, JIT-compiled
1807code). Also changed smc-check=all to smc-check=all-non-file as was done for
1808RunTest (see 4 above).
1809
181032. Implemented the PCRE2_NO_JIT option for pcre2_match().
1811
181233. Fix typo that gave a compiler error when JIT not supported.
1813
181434. Fix comment describing the returns from find_fixedlength().
1815
181635. Fix potential negative index in pcre2test.
1817
181836. Calls to pcre2_get_error_message() with error numbers that are never
1819returned by PCRE2 functions were returning empty strings. Now the error code
1820PCRE2_ERROR_BADDATA is returned. A facility has been added to pcre2test to
1821show the texts for given error numbers (i.e. to call pcre2_get_error_message()
1822and display what it returns) and a few representative error codes are now
1823checked in RunTest.
1824
182537. Added "&& !defined(__INTEL_COMPILER)" to the test for __GNUC__ in
1826pcre2_match.c, in anticipation that this is needed for the same reason it was
1827recently added to pcrecpp.cc in PCRE1.
1828
182938. Using -o with -M in pcre2grep could cause unnecessary repeated output when
1830the match extended over a line boundary, as it tried to find more matches "on
1831the same line" - but it was already over the end.
1832
183339. Allow \C in lookbehinds and DFA matching in UTF-32 mode (by converting it
1834to the same code as '.' when PCRE2_DOTALL is set).
1835
183640. Fix two clang compiler warnings in pcre2test when only one code unit width
1837is supported.
1838
183941. Upgrade RunTest to automatically re-run test 2 with a large (64MiB) stack
1840if it fails when running the interpreter with a 16MiB stack (and if changing
1841the stack size via pcre2test is possible). This avoids having to manually set a
1842large stack size when testing with clang.
1843
184442. Fix register overwite in JIT when SSE2 acceleration is enabled.
1845
184643. Detect integer overflow in pcre2test pattern and data repetition counts.
1847
184844. In pcre2test, ignore "allcaptures" after DFA matching.
1849
185045. Fix unaligned accesses on x86. Patch by Marc Mutz.
1851
185246. Fix some more clang compiler warnings.
1853
1854
1855Version 10.21 12-January-2016
1856-----------------------------
1857
18581. Improve matching speed of patterns starting with + or * in JIT.
1859
18602. Use memchr() to find the first character in an unanchored match in 8-bit
1861mode in the interpreter. This gives a significant speed improvement.
1862
18633. Removed a redundant copy of the opcode_possessify table in the
1864pcre2_auto_possessify.c source.
1865
18664. Fix typos in dftables.c for z/OS.
1867
18685. Change 36 for 10.20 broke the handling of [[:>:]] and [[:<:]] in that
1869processing them could involve a buffer overflow if the following character was
1870an opening parenthesis.
1871
18726. Change 36 for 10.20 also introduced a bug in processing this pattern:
1873/((?x)(*:0))#(?'/. Specifically: if a setting of (?x) was followed by a (*MARK)
1874setting (which (*:0) is), then (?x) did not get unset at the end of its group
1875during the scan for named groups, and hence the external # was incorrectly
1876treated as a comment and the invalid (?' at the end of the pattern was not
1877diagnosed. This caused a buffer overflow during the real compile. This bug was
1878discovered by Karl Skomski with the LLVM fuzzer.
1879
18807. Moved the pcre2_find_bracket() function from src/pcre2_compile.c into its
1881own source module to avoid a circular dependency between src/pcre2_compile.c
1882and src/pcre2_study.c
1883
18848. A callout with a string argument containing an opening square bracket, for
1885example /(?C$[$)(?<]/, was incorrectly processed and could provoke a buffer
1886overflow. This bug was discovered by Karl Skomski with the LLVM fuzzer.
1887
18889. The handling of callouts during the pre-pass for named group identification
1889has been tightened up.
1890
189110. The quantifier {1} can be ignored, whether greedy, non-greedy, or
1892possessive. This is a very minor optimization.
1893
189411. A possessively repeated conditional group that could match an empty string,
1895for example, /(?(R))*+/, was incorrectly compiled.
1896
189712. The Unicode tables have been updated to Unicode 8.0.0 (thanks to Christian
1898Persch).
1899
190013. An empty comment (?#) in a pattern was incorrectly processed and could
1901provoke a buffer overflow. This bug was discovered by Karl Skomski with the
1902LLVM fuzzer.
1903
190414. Fix infinite recursion in the JIT compiler when certain patterns such as
1905/(?:|a|){100}x/ are analysed.
1906
190715. Some patterns with character classes involving [: and \\ were incorrectly
1908compiled and could cause reading from uninitialized memory or an incorrect
1909error diagnosis. Examples are: /[[:\\](?<[::]/ and /[[:\\](?'abc')[a:]. The
1910first of these bugs was discovered by Karl Skomski with the LLVM fuzzer.
1911
191216. Pathological patterns containing many nested occurrences of [: caused
1913pcre2_compile() to run for a very long time. This bug was found by the LLVM
1914fuzzer.
1915
191617. A missing closing parenthesis for a callout with a string argument was not
1917being diagnosed, possibly leading to a buffer overflow. This bug was found by
1918the LLVM fuzzer.
1919
192018. A conditional group with only one branch has an implicit empty alternative
1921branch and must therefore be treated as potentially matching an empty string.
1922
192319. If (?R was followed by - or + incorrect behaviour happened instead of a
1924diagnostic. This bug was discovered by Karl Skomski with the LLVM fuzzer.
1925
192620. Another bug that was introduced by change 36 for 10.20: conditional groups
1927whose condition was an assertion preceded by an explicit callout with a string
1928argument might be incorrectly processed, especially if the string contained \Q.
1929This bug was discovered by Karl Skomski with the LLVM fuzzer.
1930
193121. Compiling PCRE2 with the sanitize options of clang showed up a number of
1932very pedantic coding infelicities and a buffer overflow while checking a UTF-8
1933string if the final multi-byte UTF-8 character was truncated.
1934
193522. For Perl compatibility in EBCDIC environments, ranges such as a-z in a
1936class, where both values are literal letters in the same case, omit the
1937non-letter EBCDIC code points within the range.
1938
193923. Finding the minimum matching length of complex patterns with back
1940references and/or recursions can take a long time. There is now a cut-off that
1941gives up trying to find a minimum length when things get too complex.
1942
194324. An optimization has been added that speeds up finding the minimum matching
1944length for patterns containing repeated capturing groups or recursions.
1945
194625. If a pattern contained a back reference to a group whose number was
1947duplicated as a result of appearing in a (?|...) group, the computation of the
1948minimum matching length gave a wrong result, which could cause incorrect "no
1949match" errors. For such patterns, a minimum matching length cannot at present
1950be computed.
1951
195226. Added a check for integer overflow in conditions (?(<digits>) and
1953(?(R<digits>). This omission was discovered by Karl Skomski with the LLVM
1954fuzzer.
1955
195627. Fixed an issue when \p{Any} inside an xclass did not read the current
1957character.
1958
195928. If pcre2grep was given the -q option with -c or -l, or when handling a
1960binary file, it incorrectly wrote output to stdout.
1961
196229. The JIT compiler did not restore the control verb head in case of *THEN
1963control verbs. This issue was found by Karl Skomski with a custom LLVM fuzzer.
1964
196530. The way recursive references such as (?3) are compiled has been re-written
1966because the old way was the cause of many issues. Now, conversion of the group
1967number into a pattern offset does not happen until the pattern has been
1968completely compiled. This does mean that detection of all infinitely looping
1969recursions is postponed till match time. In the past, some easy ones were
1970detected at compile time. This re-writing was done in response to yet another
1971bug found by the LLVM fuzzer.
1972
197331. A test for a back reference to a non-existent group was missing for items
1974such as \987. This caused incorrect code to be compiled. This issue was found
1975by Karl Skomski with a custom LLVM fuzzer.
1976
197732. Error messages for syntax errors following \g and \k were giving inaccurate
1978offsets in the pattern.
1979
198033. Improve the performance of starting single character repetitions in JIT.
1981
198234. (*LIMIT_MATCH=) now gives an error instead of setting the value to 0.
1983
198435. Error messages for syntax errors in *LIMIT_MATCH and *LIMIT_RECURSION now
1985give the right offset instead of zero.
1986
198736. The JIT compiler should not check repeats after a {0,1} repeat byte code.
1988This issue was found by Karl Skomski with a custom LLVM fuzzer.
1989
199037. The JIT compiler should restore the control chain for empty possessive
1991repeats. This issue was found by Karl Skomski with a custom LLVM fuzzer.
1992
199338. A bug which was introduced by the single character repetition optimization
1994was fixed.
1995
199639. Match limit check added to recursion. This issue was found by Karl Skomski
1997with a custom LLVM fuzzer.
1998
199940. Arrange for the UTF check in pcre2_match() and pcre2_dfa_match() to look
2000only at the part of the subject that is relevant when the starting offset is
2001non-zero.
2002
200341. Improve first character match in JIT with SSE2 on x86.
2004
200542. Fix two assertion fails in JIT. These issues were found by Karl Skomski
2006with a custom LLVM fuzzer.
2007
200843. Correct the setting of CMAKE_C_FLAGS in CMakeLists.txt (patch from Roy Ivy
2009III).
2010
201144. Fix bug in RunTest.bat for new test 14, and adjust the script for the added
2012test (there are now 20 in total).
2013
201445. Fixed a corner case of range optimization in JIT.
2015
201646. Add the ${*MARK} facility to pcre2_substitute().
2017
201847. Modifier lists in pcre2test were splitting at spaces without the required
2019commas.
2020
202148. Implemented PCRE2_ALT_VERBNAMES.
2022
202349. Fixed two issues in JIT. These were found by Karl Skomski with a custom
2024LLVM fuzzer.
2025
202650. The pcre2test program has been extended by adding the #newline_default
2027command. This has made it possible to run the standard tests when PCRE2 is
2028compiled with either CR or CRLF as the default newline convention. As part of
2029this work, the new command was added to several test files and the testing
2030scripts were modified. The pcre2grep tests can now also be run when there is no
2031LF in the default newline convention.
2032
203351. The RunTest script has been modified so that, when JIT is used and valgrind
2034is specified, a valgrind suppressions file is set up to ignore "Invalid read of
2035size 16" errors because these are false positives when the hardware supports
2036the SSE2 instruction set.
2037
203852. It is now possible to have comment lines amid the subject strings in
2039pcre2test (and perltest.sh) input.
2040
204153. Implemented PCRE2_USE_OFFSET_LIMIT and pcre2_set_offset_limit().
2042
204354. Add the null_context modifier to pcre2test so that calling pcre2_compile()
2044and the matching functions with NULL contexts can be tested.
2045
204655. Implemented PCRE2_SUBSTITUTE_EXTENDED.
2047
204856. In a character class such as [\W\p{Any}] where both a negative-type escape
2049("not a word character") and a property escape were present, the property
2050escape was being ignored.
2051
205257. Fixed integer overflow for patterns whose minimum matching length is very,
2053very large.
2054
205558. Implemented --never-backslash-C.
2056
205759. Change 55 above introduced a bug by which certain patterns provoked the
2058erroneous error "\ at end of pattern".
2059
206060. The special sequences [[:<:]] and [[:>:]] gave rise to incorrect compiling
2061errors or other strange effects if compiled in UCP mode. Found with libFuzzer
2062and AddressSanitizer.
2063
206461. Whitespace at the end of a pcre2test pattern line caused a spurious error
2065message if there were only single-character modifiers. It should be ignored.
2066
206762. The use of PCRE2_NO_AUTO_CAPTURE could cause incorrect compilation results
2068or segmentation errors for some patterns. Found with libFuzzer and
2069AddressSanitizer.
2070
207163. Very long names in (*MARK) or (*THEN) etc. items could provoke a buffer
2072overflow.
2073
207464. Improve error message for overly-complicated patterns.
2075
207665. Implemented an optional replication feature for patterns in pcre2test, to
2077make it easier to test long repetitive patterns. The tests for 63 above are
2078converted to use the new feature.
2079
208066. In the POSIX wrapper, if regerror() was given too small a buffer, it could
2081misbehave.
2082
208367. In pcre2_substitute() in UTF mode, the UTF validity check on the
2084replacement string was happening before the length setting when the replacement
2085string was zero-terminated.
2086
208768. In pcre2_substitute() in UTF mode, PCRE2_NO_UTF_CHECK can be set for the
2088second and subsequent calls to pcre2_match().
2089
209069. There was no check for integer overflow for a replacement group number in
2091pcre2_substitute(). An added check for a number greater than the largest group
2092number in the pattern means this is not now needed.
2093
209470. The PCRE2-specific VERSION condition didn't work correctly if only one
2095digit was given after the decimal point, or if more than two digits were given.
2096It now works with one or two digits, and gives a compile time error if more are
2097given.
2098
209971. In pcre2_substitute() there was the possibility of reading one code unit
2100beyond the end of the replacement string.
2101
210272. The code for checking a subject's UTF-32 validity for a pattern with a
2103lookbehind involved an out-of-bounds pointer, which could potentially cause
2104trouble in some environments.
2105
210673. The maximum lookbehind length was incorrectly calculated for patterns such
2107as /(?<=(a)(?-1))x/ which have a recursion within a backreference.
2108
210974. Give an error if a lookbehind assertion is longer than 65535 code units.
2110
211175. Give an error in pcre2_substitute() if a match ends before it starts (as a
2112result of the use of \K).
2113
211476. Check the length of subpattern names and the names in (*MARK:xx) etc.
2115dynamically to avoid the possibility of integer overflow.
2116
211777. Implement pcre2_set_max_pattern_length() so that programs can restrict the
2118size of patterns that they are prepared to handle.
2119
212078. (*NO_AUTO_POSSESS) was not working.
2121
212279. Adding group information caching improves the speed of compiling when
2123checking whether a group has a fixed length and/or could match an empty string,
2124especially when recursion or subroutine calls are involved. However, this
2125cannot be used when (?| is present in the pattern because the same number may
2126be used for groups of different sizes. To catch runaway patterns in this
2127situation, counts have been introduced to the functions that scan for empty
2128branches or compute fixed lengths.
2129
213080. Allow for the possibility of the size of the nest_save structure not being
2131a factor of the size of the compiling workspace (it currently is).
2132
213381. Check for integer overflow in minimum length calculation and cap it at
213465535.
2135
213682. Small optimizations in code for finding the minimum matching length.
2137
213883. Lock out configuring for EBCDIC with non-8-bit libraries.
2139
214084. Test for error code <= 0 in regerror().
2141
214285. Check for too many replacements (more than INT_MAX) in pcre2_substitute().
2143
214486. Avoid the possibility of computing with an out-of-bounds pointer (though
2145not dereferencing it) while handling lookbehind assertions.
2146
214787. Failure to get memory for the match data in regcomp() is now given as a
2148regcomp() error instead of waiting for regexec() to pick it up.
2149
215088. In pcre2_substitute(), ensure that CRLF is not split when it is a valid
2151newline sequence.
2152
215389. Paranoid check in regcomp() for bad error code from pcre2_compile().
2154
215590. Run test 8 (internal offsets and code sizes) for link sizes 3 and 4 as well
2156as for link size 2.
2157
215891. Document that JIT has a limit on pattern size, and give more information
2159about JIT compile failures in pcre2test.
2160
216192. Implement PCRE2_INFO_HASBACKSLASHC.
2162
216393. Re-arrange valgrind support code in pcre2test to avoid spurious reports
2164with JIT (possibly caused by SSE2?).
2165
216694. Support offset_limit in JIT.
2167
216895. A sequence such as [[:punct:]b] that is, a POSIX character class followed
2169by a single ASCII character in a class item, was incorrectly compiled in UCP
2170mode. The POSIX class got lost, but only if the single character followed it.
2171
217296. [:punct:] in UCP mode was matching some characters in the range 128-255
2173that should not have been matched.
2174
217597. If [:^ascii:] or [:^xdigit:] are present in a non-negated class, all
2176characters with code points greater than 255 are in the class. When a Unicode
2177property was also in the class (if PCRE2_UCP is set, escapes such as \w are
2178turned into Unicode properties), wide characters were not correctly handled,
2179and could fail to match.
2180
218198. In pcre2test, make the "startoffset" modifier a synonym of "offset",
2182because it sets the "startoffset" parameter for pcre2_match().
2183
218499. If PCRE2_AUTO_CALLOUT was set on a pattern that had a (?# comment between
2185an item and its qualifier (for example, A(?#comment)?B) pcre2_compile()
2186misbehaved. This bug was found by the LLVM fuzzer.
2187
2188100. The error for an invalid UTF pattern string always gave the code unit
2189offset as zero instead of where the invalidity was found.
2190
2191101. Further to 97 above, negated classes such as [^[:^ascii:]\d] were also not
2192working correctly in UCP mode.
2193
2194102. Similar to 99 above, if an isolated \E was present between an item and its
2195qualifier when PCRE2_AUTO_CALLOUT was set, pcre2_compile() misbehaved. This bug
2196was found by the LLVM fuzzer.
2197
2198103. The POSIX wrapper function regexec() crashed if the option REG_STARTEND
2199was set when the pmatch argument was NULL. It now returns REG_INVARG.
2200
2201104. Allow for up to 32-bit numbers in the ordin() function in pcre2grep.
2202
2203105. An empty \Q\E sequence between an item and its qualifier caused
2204pcre2_compile() to misbehave when auto callouts were enabled. This bug
2205was found by the LLVM fuzzer.
2206
2207106. If both PCRE2_ALT_VERBNAMES and PCRE2_EXTENDED were set, and a (*MARK) or
2208other verb "name" ended with whitespace immediately before the closing
2209parenthesis, pcre2_compile() misbehaved. Example: /(*:abc )/, but only when
2210both those options were set.
2211
2212107. In a number of places pcre2_compile() was not handling NULL characters
2213correctly, and pcre2test with the "bincode" modifier was not always correctly
2214displaying fields containing NULLS:
2215
2216 (a) Within /x extended #-comments
2217 (b) Within the "name" part of (*MARK) and other *verbs
2218 (c) Within the text argument of a callout
2219
2220108. If a pattern that was compiled with PCRE2_EXTENDED started with white
2221space or a #-type comment that was followed by (?-x), which turns off
2222PCRE2_EXTENDED, and there was no subsequent (?x) to turn it on again,
2223pcre2_compile() assumed that (?-x) applied to the whole pattern and
2224consequently mis-compiled it. This bug was found by the LLVM fuzzer. The fix
2225for this bug means that a setting of any of the (?imsxJU) options at the start
2226of a pattern is no longer transferred to the options that are returned by
2227PCRE2_INFO_ALLOPTIONS. In fact, this was an anachronism that should have
2228changed when the effects of those options were all moved to compile time.
2229
2230109. An escaped closing parenthesis in the "name" part of a (*verb) when
2231PCRE2_ALT_VERBNAMES was set caused pcre2_compile() to malfunction. This bug
2232was found by the LLVM fuzzer.
2233
2234110. Implemented PCRE2_SUBSTITUTE_UNSET_EMPTY, and updated pcre2test to make it
2235possible to test it.
2236
2237111. "Harden" pcre2test against ridiculously large values in modifiers and
2238command line arguments.
2239
2240112. Implemented PCRE2_SUBSTITUTE_UNKNOWN_UNSET and PCRE2_SUBSTITUTE_OVERFLOW_
2241LENGTH.
2242
2243113. Fix printing of *MARK names that contain binary zeroes in pcre2test.
2244
2245
2246Version 10.20 30-June-2015
2247--------------------------
2248
22491. Callouts with string arguments have been added.
2250
22512. Assertion code generator in JIT has been optimized.
2252
22533. The invalid pattern (?(?C) has a missing assertion condition at the end. The
2254pcre2_compile() function read past the end of the input before diagnosing an
2255error. This bug was discovered by the LLVM fuzzer.
2256
22574. Implemented pcre2_callout_enumerate().
2258
22595. Fix JIT compilation of conditional blocks whose assertion is converted to
2260(*FAIL). E.g: /(?(?!))/.
2261
22626. The pattern /(?(?!)^)/ caused references to random memory. This bug was
2263discovered by the LLVM fuzzer.
2264
22657. The assertion (?!) is optimized to (*FAIL). This was not handled correctly
2266when this assertion was used as a condition, for example (?(?!)a|b). In
2267pcre2_match() it worked by luck; in pcre2_dfa_match() it gave an incorrect
2268error about an unsupported item.
2269
22708. For some types of pattern, for example /Z*(|d*){216}/, the auto-
2271possessification code could take exponential time to complete. A recursion
2272depth limit of 1000 has been imposed to limit the resources used by this
2273optimization. This infelicity was discovered by the LLVM fuzzer.
2274
22759. A pattern such as /(*UTF)[\S\V\H]/, which contains a negated special class
2276such as \S in non-UCP mode, explicit wide characters (> 255) can be ignored
2277because \S ensures they are all in the class. The code for doing this was
2278interacting badly with the code for computing the amount of space needed to
2279compile the pattern, leading to a buffer overflow. This bug was discovered by
2280the LLVM fuzzer.
2281
228210. A pattern such as /((?2)+)((?1))/ which has mutual recursion nested inside
2283other kinds of group caused stack overflow at compile time. This bug was
2284discovered by the LLVM fuzzer.
2285
228611. A pattern such as /(?1)(?#?'){8}(a)/ which had a parenthesized comment
2287between a subroutine call and its quantifier was incorrectly compiled, leading
2288to buffer overflow or other errors. This bug was discovered by the LLVM fuzzer.
2289
229012. The illegal pattern /(?(?<E>.*!.*)?)/ was not being diagnosed as missing an
2291assertion after (?(. The code was failing to check the character after (?(?<
2292for the ! or = that would indicate a lookbehind assertion. This bug was
2293discovered by the LLVM fuzzer.
2294
229513. A pattern such as /X((?2)()*+){2}+/ which has a possessive quantifier with
2296a fixed maximum following a group that contains a subroutine reference was
2297incorrectly compiled and could trigger buffer overflow. This bug was discovered
2298by the LLVM fuzzer.
2299
230014. Negative relative recursive references such as (?-7) to non-existent
2301subpatterns were not being diagnosed and could lead to unpredictable behaviour.
2302This bug was discovered by the LLVM fuzzer.
2303
230415. The bug fixed in 14 was due to an integer variable that was unsigned when
2305it should have been signed. Some other "int" variables, having been checked,
2306have either been changed to uint32_t or commented as "must be signed".
2307
230816. A mutual recursion within a lookbehind assertion such as (?<=((?2))((?1)))
2309caused a stack overflow instead of the diagnosis of a non-fixed length
2310lookbehind assertion. This bug was discovered by the LLVM fuzzer.
2311
231217. The use of \K in a positive lookbehind assertion in a non-anchored pattern
2313(e.g. /(?<=\Ka)/) could make pcre2grep loop.
2314
231518. There was a similar problem to 17 in pcre2test for global matches, though
2316the code there did catch the loop.
2317
231819. If a greedy quantified \X was preceded by \C in UTF mode (e.g. \C\X*),
2319and a subsequent item in the pattern caused a non-match, backtracking over the
2320repeated \X did not stop, but carried on past the start of the subject, causing
2321reference to random memory and/or a segfault. There were also some other cases
2322where backtracking after \C could crash. This set of bugs was discovered by the
2323LLVM fuzzer.
2324
232520. The function for finding the minimum length of a matching string could take
2326a very long time if mutual recursion was present many times in a pattern, for
2327example, /((?2){73}(?2))((?1))/. A better mutual recursion detection method has
2328been implemented. This infelicity was discovered by the LLVM fuzzer.
2329
233021. Implemented PCRE2_NEVER_BACKSLASH_C.
2331
233222. The feature for string replication in pcre2test could read from freed
2333memory if the replication required a buffer to be extended, and it was not
2334working properly in 16-bit and 32-bit modes. This issue was discovered by a
2335fuzzer: see http://lcamtuf.coredump.cx/afl/.
2336
233723. Added the PCRE2_ALT_CIRCUMFLEX option.
2338
233924. Adjust the treatment of \8 and \9 to be the same as the current Perl
2340behaviour.
2341
234225. Static linking against the PCRE2 library using the pkg-config module was
2343failing on missing pthread symbols.
2344
234526. If a group that contained a recursive back reference also contained a
2346forward reference subroutine call followed by a non-forward-reference
2347subroutine call, for example /.((?2)(?R)\1)()/, pcre2_compile() failed to
2348compile correct code, leading to undefined behaviour or an internally detected
2349error. This bug was discovered by the LLVM fuzzer.
2350
235127. Quantification of certain items (e.g. atomic back references) could cause
2352incorrect code to be compiled when recursive forward references were involved.
2353For example, in this pattern: /(?1)()((((((\1++))\x85)+)|))/. This bug was
2354discovered by the LLVM fuzzer.
2355
235628. A repeated conditional group whose condition was a reference by name caused
2357a buffer overflow if there was more than one group with the given name. This
2358bug was discovered by the LLVM fuzzer.
2359
236029. A recursive back reference by name within a group that had the same name as
2361another group caused a buffer overflow. For example: /(?J)(?'d'(?'d'\g{d}))/.
2362This bug was discovered by the LLVM fuzzer.
2363
236430. A forward reference by name to a group whose number is the same as the
2365current group, for example in this pattern: /(?|(\k'Pm')|(?'Pm'))/, caused a
2366buffer overflow at compile time. This bug was discovered by the LLVM fuzzer.
2367
236831. Fix -fsanitize=undefined warnings for left shifts of 1 by 31 (it treats 1
2369as an int; fixed by writing it as 1u).
2370
237132. Fix pcre2grep compile when -std=c99 is used with gcc, though it still gives
2372a warning for "fileno" unless -std=gnu99 us used.
2373
237433. A lookbehind assertion within a set of mutually recursive subpatterns could
2375provoke a buffer overflow. This bug was discovered by the LLVM fuzzer.
2376
237734. Give an error for an empty subpattern name such as (?'').
2378
237935. Make pcre2test give an error if a pattern that follows #forbud_utf contains
2380\P, \p, or \X.
2381
238236. The way named subpatterns are handled has been refactored. There is now a
2383pre-pass over the regex which does nothing other than identify named
2384subpatterns and count the total captures. This means that information about
2385named patterns is known before the rest of the compile. In particular, it means
2386that forward references can be checked as they are encountered. Previously, the
2387code for handling forward references was contorted and led to several errors in
2388computing the memory requirements for some patterns, leading to buffer
2389overflows.
2390
239137. There was no check for integer overflow in subroutine calls such as (?123).
2392
239338. The table entry for \l in EBCDIC environments was incorrect, leading to its
2394being treated as a literal 'l' instead of causing an error.
2395
239639. If a non-capturing group containing a conditional group that could match
2397an empty string was repeated, it was not identified as matching an empty string
2398itself. For example: /^(?:(?(1)x|)+)+$()/.
2399
240040. In an EBCDIC environment, pcretest was mishandling the escape sequences
2401\a and \e in test subject lines.
2402
240341. In an EBCDIC environment, \a in a pattern was converted to the ASCII
2404instead of the EBCDIC value.
2405
240642. The handling of \c in an EBCDIC environment has been revised so that it is
2407now compatible with the specification in Perl's perlebcdic page.
2408
240943. Single character repetition in JIT has been improved. 20-30% speedup
2410was achieved on certain patterns.
2411
241244. The EBCDIC character 0x41 is a non-breaking space, equivalent to 0xa0 in
2413ASCII/Unicode. This has now been added to the list of characters that are
2414recognized as white space in EBCDIC.
2415
241645. When PCRE2 was compiled without Unicode support, the use of \p and \P gave
2417an error (correctly) when used outside a class, but did not give an error
2418within a class.
2419
242046. \h within a class was incorrectly compiled in EBCDIC environments.
2421
242247. JIT should return with error when the compiled pattern requires
2423more stack space than the maximum.
2424
242548. Fixed a memory leak in pcre2grep when a locale is set.
2426
2427
2428Version 10.10 06-March-2015
2429---------------------------
2430
24311. When a pattern is compiled, it remembers the highest back reference so that
2432when matching, if the ovector is too small, extra memory can be obtained to
2433use instead. A conditional subpattern whose condition is a check on a capture
2434having happened, such as, for example in the pattern /^(?:(a)|b)(?(1)A|B)/, is
2435another kind of back reference, but it was not setting the highest
2436backreference number. This mattered only if pcre2_match() was called with an
2437ovector that was too small to hold the capture, and there was no other kind of
2438back reference (a situation which is probably quite rare). The effect of the
2439bug was that the condition was always treated as FALSE when the capture could
2440not be consulted, leading to a incorrect behaviour by pcre2_match(). This bug
2441has been fixed.
2442
24432. Functions for serialization and deserialization of sets of compiled patterns
2444have been added.
2445
24463. The value that is returned by PCRE2_INFO_SIZE has been corrected to remove
2447excess code units at the end of the data block that may occasionally occur if
2448the code for calculating the size over-estimates. This change stops the
2449serialization code copying uninitialized data, to which valgrind objects. The
2450documentation of PCRE2_INFO_SIZE was incorrect in stating that the size did not
2451include the general overhead. This has been corrected.
2452
24534. All code units in every slot in the table of group names are now set, again
2454in order to avoid accessing uninitialized data when serializing.
2455
24565. The (*NO_JIT) feature is implemented.
2457
24586. If a bug that caused pcre2_compile() to use more memory than allocated was
2459triggered when using valgrind, the code in (3) above passed a stupidly large
2460value to valgrind. This caused a crash instead of an "internal error" return.
2461
24627. A reference to a duplicated named group (either a back reference or a test
2463for being set in a conditional) that occurred in a part of the pattern where
2464PCRE2_DUPNAMES was not set caused the amount of memory needed for the pattern
2465to be incorrectly calculated, leading to overwriting.
2466
24678. A mutually recursive set of back references such as (\2)(\1) caused a
2468segfault at compile time (while trying to find the minimum matching length).
2469The infinite loop is now broken (with the minimum length unset, that is, zero).
2470
24719. If an assertion that was used as a condition was quantified with a minimum
2472of zero, matching went wrong. In particular, if the whole group had unlimited
2473repetition and could match an empty string, a segfault was likely. The pattern
2474(?(?=0)?)+ is an example that caused this. Perl allows assertions to be
2475quantified, but not if they are being used as conditions, so the above pattern
2476is faulted by Perl. PCRE2 has now been changed so that it also rejects such
2477patterns.
2478
247910. The error message for an invalid quantifier has been changed from "nothing
2480to repeat" to "quantifier does not follow a repeatable item".
2481
248211. If a bad UTF string is compiled with NO_UTF_CHECK, it may succeed, but
2483scanning the compiled pattern in subsequent auto-possessification can get out
2484of step and lead to an unknown opcode. Previously this could have caused an
2485infinite loop. Now it generates an "internal error" error. This is a tidyup,
2486not a bug fix; passing bad UTF with NO_UTF_CHECK is documented as having an
2487undefined outcome.
2488
248912. A UTF pattern containing a "not" match of a non-ASCII character and a
2490subroutine reference could loop at compile time. Example: /[^\xff]((?1))/.
2491
249213. The locale test (RunTest 3) has been upgraded. It now checks that a locale
2493that is found in the output of "locale -a" can actually be set by pcre2test
2494before it is accepted. Previously, in an environment where a locale was listed
2495but would not set (an example does exist), the test would "pass" without
2496actually doing anything. Also the fr_CA locale has been added to the list of
2497locales that can be used.
2498
249914. Fixed a bug in pcre2_substitute(). If a replacement string ended in a
2500capturing group number without parentheses, the last character was incorrectly
2501literally included at the end of the replacement string.
2502
250315. A possessive capturing group such as (a)*+ with a minimum repeat of zero
2504failed to allow the zero-repeat case if pcre2_match() was called with an
2505ovector too small to capture the group.
2506
250716. Improved error message in pcre2test when setting the stack size (-S) fails.
2508
250917. Fixed two bugs in CMakeLists.txt: (1) Some lines had got lost in the
2510transfer from PCRE1, meaning that CMake configuration failed if "build tests"
2511was selected. (2) The file src/pcre2_serialize.c had not been added to the list
2512of PCRE2 sources, which caused a failure to build pcre2test.
2513
251418. Fixed typo in pcre2_serialize.c (DECL instead of DEFN) that causes problems
2515only on Windows.
2516
251719. Use binary input when reading back saved serialized patterns in pcre2test.
2518
251920. Added RunTest.bat for running the tests under Windows.
2520
252121. "make distclean" was not removing config.h, a file that may be created for
2522use with CMake.
2523
252422. A pattern such as "((?2){0,1999}())?", which has a group containing a
2525forward reference repeated a large (but limited) number of times within a
2526repeated outer group that has a zero minimum quantifier, caused incorrect code
2527to be compiled, leading to the error "internal error: previously-checked
2528referenced subpattern not found" when an incorrect memory address was read.
2529This bug was reported as "heap overflow", discovered by Kai Lu of Fortinet's
2530FortiGuard Labs. (Added 24-March-2015: CVE-2015-2325 was given to this.)
2531
253223. A pattern such as "((?+1)(\1))/" containing a forward reference subroutine
2533call within a group that also contained a recursive back reference caused
2534incorrect code to be compiled. This bug was reported as "heap overflow",
2535discovered by Kai Lu of Fortinet's FortiGuard Labs. (Added 24-March-2015:
2536CVE-2015-2326 was given to this.)
2537
253824. Computing the size of the JIT read-only data in advance has been a source
2539of various issues, and new ones are still appear unfortunately. To fix
2540existing and future issues, size computation is eliminated from the code,
2541and replaced by on-demand memory allocation.
2542
254325. A pattern such as /(?i)[A-`]/, where characters in the other case are
2544adjacent to the end of the range, and the range contained characters with more
2545than one other case, caused incorrect behaviour when compiled in UTF mode. In
2546that example, the range a-j was left out of the class.
2547
2548
2549Version 10.00 05-January-2015
2550-----------------------------
2551
2552Version 10.00 is the first release of PCRE2, a revised API for the PCRE
2553library. Changes prior to 10.00 are logged in the ChangeLog file for the old
2554API, up to item 20 for release 8.36.
2555
2556The code of the library was heavily revised as part of the new API
2557implementation. Details of each and every modification were not individually
2558logged. In addition to the API changes, the following changes were made. They
2559are either new functionality, or bug fixes and other noticeable changes of
2560behaviour that were implemented after the code had been forked.
2561
25621. Including Unicode support at build time is now enabled by default, but it
2563can optionally be disabled. It is not enabled by default at run time (no
2564change).
2565
25662. The test program, now called pcre2test, was re-specified and almost
2567completely re-written. Its input is not compatible with input for pcretest.
2568
25693. Patterns may start with (*NOTEMPTY) or (*NOTEMPTY_ATSTART) to set the
2570PCRE2_NOTEMPTY or PCRE2_NOTEMPTY_ATSTART options for every subject line that is
2571matched by that pattern.
2572
25734. For the benefit of those who use PCRE2 via some other application, that is,
2574not writing the function calls themselves, it is possible to check the PCRE2
2575version by matching a pattern such as /(?(VERSION>=10)yes|no)/ against a
2576string such as "yesno".
2577
25785. There are case-equivalent Unicode characters whose encodings use different
2579numbers of code units in UTF-8. U+023A and U+2C65 are one example. (It is
2580theoretically possible for this to happen in UTF-16 too.) If a backreference to
2581a group containing one of these characters was greedily repeated, and during
2582the match a backtrack occurred, the subject might be backtracked by the wrong
2583number of code units. For example, if /^(\x{23a})\1*(.)/ is matched caselessly
2584(and in UTF-8 mode) against "\x{23a}\x{2c65}\x{2c65}\x{2c65}", group 2 should
2585capture the final character, which is the three bytes E2, B1, and A5 in UTF-8.
2586Incorrect backtracking meant that group 2 captured only the last two bytes.
2587This bug has been fixed; the new code is slower, but it is used only when the
2588strings matched by the repetition are not all the same length.
2589
25906. A pattern such as /()a/ was not setting the "first character must be 'a'"
2591information. This applied to any pattern with a group that matched no
2592characters, for example: /(?:(?=.)|(?<!x))a/.
2593
25947. When an (*ACCEPT) is triggered inside capturing parentheses, it arranges for
2595those parentheses to be closed with whatever has been captured so far. However,
2596it was failing to mark any other groups between the highest capture so far and
2597the currrent group as "unset". Thus, the ovector for those groups contained
2598whatever was previously there. An example is the pattern /(x)|((*ACCEPT))/ when
2599matched against "abcd".
2600
26018. The pcre2_substitute() function has been implemented.
2602
26039. If an assertion used as a condition was quantified with a minimum of zero
2604(an odd thing to do, but it happened), SIGSEGV or other misbehaviour could
2605occur.
2606
260710. The PCRE2_NO_DOTSTAR_ANCHOR option has been implemented.
2608
2609****