xref: /aosp_15_r20/external/pcre/ChangeLog (revision 22dc650d8ae982c6770746019a6f94af92b0f024)
1Change Log for PCRE2
2--------------------
3
4Before the move to GitHub, this was the only record of changes to PCRE2. Now
5there is also the log of commit messages.
6
7Version 10.44 07-June-2024
8--------------------------
9
101. If a pattern contained a variable-length lookbehind in which the first
11branch was not the one with the shortest minimum length, and the lookbehind
12contained a capturing group, and elsewhere in the pattern there was another
13lookbehind that referenced that group, the pattern was incorrectly compiled,
14leading to unpredictable results, including crashes in JIT compiling. An
15example pattern is: /(((?<=123?456456|ABC)))(?<=\2)/
16
172. Further updates to the oss-fuzz support:
18
19   (a) Limit quantifiers for groups and classes to be no more than 10. This
20       avoids very long JIT compile times that happen in some cases when groups
21       are replicated for quantification, and very long match times when
22       classes contain a lot of non-ascii characters.
23
24   (b) Added PCRE2_EXTENDED_MORE to the list of allowed options.
25
26   (c) Arranged for text error messages to be shown in 16-bit and 32-bit modes.
27
28   (d) Made the output in standalone mode more readable.
29
30   (e) General code tidies.
31
32   (f) Limit the size of compiled patterns to 10MB (see 6 below).
33
34   (g) Do not run JIT on patterns whose compiled length is greater than 200K
35       bytes because this takes a long time, causing oss-fuzz to time out.
36
37   (h) Avoid compiling or matching twice with the same options (this could
38       happen if the input didn't set any options).
39
403. Increase the maximum length of a name for a group from 32 to 128 because
41there is a user for whom 32 is too small.
42
434. Cause pcre2test to output a message when pcre2_jit_compile() gives an error
44return if either jitverify or info is specified.
45
465. Some auxiliary files for building under OpenVMS that were contributed by
47Alexey Chupahin have been installed.
48
496. Added pcre2_set_max_pattern_compiled_length() to limit the size of compiled
50patterns.
51
527. There was a bug in the implementation of \X caused by my (PH) misreading or
53misunderstanding one of the grapheme sequence breaking rules in Unicode Annex
54#29. A break should occur between two characters with the Extended Pictographic
55break property unless a zero-width joiner intervenes. PCRE2 was not insisting
56on the ZWJ, causing \X to match more than it should. See GitHub issue #410.
57
588. Avoid compilation issues with proprietary compilers in UNIX since 10.43.
59
60
61Version 10.43 16-February-2024
62------------------------------
63
641. The test program added by change 2 of 10.42 didn't work when the default
65newline setting didn't include \n as a newline. One test needed (*LF) to ensure
66that it worked.
67
682. Added the new freestanding POSIX test program to the ManyConfigTests script
69in the maint directory (overlooked in 2 below). Also improved the selection
70facilities in that script, and added a test with JIT in a non-source directory,
71fixing an oversight that would have made such a test fail before.
72
733. Added pcre2_get_match_data_heapframes_size() and related pcre2test flags
74to allow for finer control of the heap used when pcre2_match() without JIT is
75used and the match_data might be reused. This began as PR #191, but has had
76further refinement and documentation edits.
77
784. Applied PR #181, which tidies some casts in pcre2_valid_utf.c.
79
805. Applied PR #184, which avoids overflow issues with the heap limit
81(introduced in 10.41/9).
82
836. Applied PR #192, which changes the timing units for pcre2test from
84milliseconds to microseconds. This is more useful for modern CPUs.
85
867. Applied PR #193, which makes the requirement for C99 explicit in
87configure.ac and CMakeLists.txt.
88
898. Fixed a bug in pcre2test when a ridiculously large string repeat required a
90stupid amount of memory. It now gives a clean realloc() failure error.
91
929. Updates to restrict the interaction between ASCII and non-ASCII characters
93for caseless matching and items like \d:
94
95   (a) Added PCRE2_EXTRA_CASELESS_RESTRICT to lock out mixing of ASCII and
96       non-ASCII when matching caselessly. This is also /r in pcre2test and
97       (?r) within patterns.
98
99   (b) Added PCRE2_EXTRA_ASCII_{BSD,BSS,BSW,POSIX} and corresponding (?aD) etc
100       in patterns and /a in pcre2test.
101
102   (c) Corresponding updates to pcre2test.
103
10410. Unicode has been updated to 15.0.0.
105
10611. The Python scripts and ucptest.c in maint have been updated (a) a minor
107change needed for 9(a) above; (b) fix bugs in ucptest,
108
10912. Integer overflow testing is now centralized in a new function.
110
11113. Made PCRE2_UCP the default in UTF mode in pcre2grep, and added new options
112--case-restrict and --no-ucp.
113
11414. In the debugging printint module (which is normally only linked into
115pcre2test), avoid the use of a variable called "not" because that's deprecated
116in C and forbidden in C++. Also rewrite some code to avoid a goto into a block
117that bypassed its initialization (though it didn't actually matter).
118
11915. More minor code adjustments to avoid using reserved C++ words as variable
120names ("new" and "typename") and another jump that bypassed an (irrelevant)
121initialization.
122
12316. Merged a pull request that removed pcre2_ucptables.c from the list of files
124to compile in NON-AUTOTOOLS-BUILD because it is #included in pcre2_tables.c.
125Also adjusted the BUILD.bazel and build.zig files, which had the same issue. At
126the same time, fixed a typo in the Bazel file.
127
12817. Add PCRE2_EXTRA_ASCII_DIGIT to allow [:digit:] to be kept on sync with \d
129even in UCP mode.
130
13118. Fix an invalid match of ascii word classes when invalid utf is enabled.
132
13319. Add a --posix-digit to pcre2grep for compatibility with GNU grep, and
134other tools that prefer the POSIX compatible unicode definition for \d.
135
13620. Report the bit width of the library in use by pcre2test for usability.
137
13821. A pathological pattern conversion test could result in a string longer than
139the available input buffer. Cause such a test to fail.
140
14122. Add a check that forces a compiler error if PCRE2_CODE_UNIT_WIDTH is not 8,
14216, or 32 when compiling any of the library modules.
143
14423. Update pcre2_compile() to treat a NULL pattern with zero length as an empty
145string.
146
14724. Add support for limited-length variable-length lookbehind assertions, with
148default maximum length 255 characters (same as Perl) but with a function to
149adjust the limit.
150
15125. Applied pull request #262, which updates the zig configuration, and #278
152which fixes a bug with out-of-source-tree CMake build testing.
153
15426. Add support for LoongArch to JIT.
155
15627. Fixed a bug in pcre2_match() in the code for handling the vector of
157backtracking frames on the heap, which caused a heap overflow if *LIMIT_HEAP
158restricted an attempt to extend to less than the frame size. Generally tidy up
159the code for extending the heap frames vector. This fixes GitHub issue #275.
160
16128. Update pcre2_fuzzsupport.c to avoid clang sanitize complaint about shifting
162left by 16 when there are non-zeros in the top 16 bits.
163
16429. Perl 5.34.0 changed the meaning of (for example) {,3} which did not used to
165be treated as a quantifier. Now it is interpreted as {0,3} and PCRE2 has
166changed to match. Note that {,} is still not a quantifier.
167
16830. Perl allows spaces and/or horizontal tabs after { or before } in all items
169that use braces, and also before or after the comma in quantifiers. PCRE2 now
170does the same, except for \u{...}, which is recognized only when
171PCRE2_EXTRA_ALT_BSUX is set. This an ECMAScript, non-Perl compatible,
172extension, so PCRE2 follows ECMAScript rather than Perl.
173
17431. Applied pull request #300 by Carlo, which fixes #261. The bug was that
175pcre2_match() was not fully resetting all captures that had been set within a
176(possibly recursive) subroutine call such as (?3).
177
17832. Changed the meaning of \w (and its synonyms) in UCP mode to match Perl. It
179now matches characters whose general categories are L or N or whose particular
180categories are Mn (non-spacing mark) or Pc (combining punctuation). The latter
181includes underscore.
182
18333. Changed the meaning of [:xdigit:] in UCP mode to match Perl. It now also
184matches the "fullwidth" versions of the hex digits. Just like it is done for
185[:digit:], PCRE2_EXTRA_ASCII_DIGIT can be used to keep this class ASCII only
186without affecting other POSIX classes.
187
18834. GitHub PR305 fixes a potential integer overflow in pcre2_dfa_match().
189
19035. Updated handling of \b and \B in UCP mode to match the changes to \w in 32
191above because \b and \B are defined in terms of \w.
192
19336. Within a pattern (?aT) and (?-aT) set and reset the PCRE2_EXTRA_ASCII_DIGIT
194option, and (?aP) also sets (?aT) so that (?-aP) disables all ASCII
195restrictions on POSIX classes.
196
19737. If PCRE2_FIRSTLINE was set on an anchored pattern, pcre2_match() and
198pcre2_dfa_match() misbehaved. PCRE2_FIRSTLINE is now ignored for anchored
199patterns.
200
20138. Add a test for ridiculous ovector offset values to the substring extraction
202functions.
203
20439. Make OP_REVERSE use IMM2_SIZE for its data instead of LINK_SIZE, for
205consistency with OP_VREVERSE.
206
20740. In some legacy environments with a pre C99 snprintf, pcre2_regerror could
208return an incorrect value when the provided buffer was too small.
209
21041. Applied pull request #342 which adds sanity checks for ctype functions and
211locks out any accidental sign-extension.
212
21342. In the 32-bit library, in non-UTF mode, a quantifier that followed a
214literal character with a value greater than or equal to 0x80000000u caused
215undefined behaviour.
216
21743. \z was misbehaving when matching fragments inside invalid UTF strings.
218
21944. Implement --group-separator and --no-group-separator for pcre2grep.
220
22145. Fix \X matching in 32 bit mode without UTF in JIT.
222
22346. Fix backref iterators when PCRE2_MATCH_UNSET_BACKREF is set in JIT.
224
22547. Refactor the handling of whole-pattern recursion (?0) in pcre2_match() so
226that its end is handled similarly to other recursions. This has altered the
227behaviour of   /|(?0)./endanchored   which was previously not right.
228
22948. Improved the test for looping recursion by checking the last referenced
230character as well as the current character. This allows some patterns that
231previously triggered the check to run to completion instead of giving the loop
232error.
233
23449. In 32-bit mode, the compiler looped for the pattern /[\x{ffffffff}]/ when
235PCRE2_CASELESS and PCRE2_UCP (but not PCRE2_UTF) were set. Fixed by not trying
236to look for other cases for characters above the Unicode range.
237
23850. In caseless 32-bit mode with UCP (but not UTF) set, the character
2390xffffffff incorrectly matched any character that has more than one other case,
240in particular k and s.
241
24251. Fix accept and endanchored interaction in JIT.
243
24452. Fix backreferences with unset backref and non-greedy iterators in JIT.
245
24653. Improve the logic that checks for a list of starting code units -- positive
247lookahead assertions are now ignored if the immediately following item is one
248that sets a mandatory starting character. For example, /a?(?=bc|)d/ used to set
249all of a, b, and d as possible starting code units; now it sets only a and d.
250
25154. Fix incorrect class character matches in JIT.
252
25355. In pcre2test, ensure pcre2_jit_match() is used when jitfast is used with
254substitution testing.
255
25656. Insert omitted setting of subject length in match data at the end of
257pcre2_jit_match().
258
25957. Implemented PCRE2_DISABLE_RECURSELOOP_CHECK for pcre2_match() to enable
260some apparently looping recursions to run to completion and therefore match the
261JIT behaviour. With this set, real loops will eventually get caught by match or
262heap limits or run out of resource.
263
26458. AC did a lot of work on pcre2_fuzzsupport.c to extend it to 16-bit and
26532-bit libraries and to compare JIT and non-JIT matching.
266
267
268Version 10.42 11-December-2022
269------------------------------
270
2711. Change 19 of 10.41 wasn't quite right; it put the definition of a default,
272empty value for PCRE2_CALL_CONVENTION in src/pcre2posix.c instead of
273src/pcre2posix.h, which meant that programs that included pcre2posix.h but not
274pcre2.h failed to compile.
275
2762. To catch similar issues to the above in future, a new small test program
277that includes pcre2posix.h but not pcre2.h has been added to the test suite.
278
2793. When the -S option of pcre2test was used to set a stack size greater than
280the allowed maximum, the error message displayed the hard limit incorrectly.
281This was pointed out on GitHub pull request #171, but the suggested patch
282didn't cope with all cases. Some further modification was required.
283
2844. Supplying an ovector count of more than 65535 to pcre2_match_data_create()
285caused a crash because the field in the match data block is only 16 bits. A
286maximum of 65535 is now silently applied.
287
2885. Merged @carenas patch #175 which fixes #86 - segfault on aarch64 (ARM),
289
2906. The prototype for pcre2_substring_list_free() specified its argument as
291PCRE2_SPTR * which is a const data type, whereas the yield from
292pcre2_substring_list() is not const. This caused compiler warnings. I have
293changed the argument of pcre2_substring_list_free() to be PCRE2_UCHAR ** to
294remove this anomaly. This might cause new warnings in existing code where a
295cast has been used to avoid previous ones.
296
297
298Version 10.41 06-December-2022
299------------------------------
300
3011. Add fflush() before and after a fork callout in pcre2grep to get its output
302to be the same on all systems. (There were previously ordering differences in
303Alpine Linux).
304
3052. Merged patch from @carenas (GitHub #110) for pthreads support in CMake.
306
3073. SSF scorecards grumbled about possible overflow in an expression in
308pcre2test. It never would have overflowed in practice, but some casts have been
309added and at the some time there's been some tidying of fprints that output
310size_t values.
311
3124. PR #94 showed up an unused enum in pcre2_convert.c, which is now removed.
313
3145. Minor code re-arrangement to remove gcc warning about realloc() in
315pcre2test.
316
3176. Change a number of int variables that hold buffer and line lengths in
318pcre2grep to PCRE2_SIZE (aka size_t).
319
3207. Added an #ifdef to cut out a call to PRIV(jit_free) when JIT is not
321supported (even though that function would do nothing in that case) at the
322request of a user who doesn't even want to link with pcre_jit_compile.o. Also
323tidied up an untidy #ifdef arrangement in pcre2test.
324
3258. Fixed an issue in the backtracking optimization of character repeats in
326JIT. Furthermore optimize star repetitions, not just plus repetitions.
327
3289. Removed the use of an initial backtracking frames vector on the system stack
329in pcre2_match() so that it now always uses the heap. (In a multi-thread
330environment with very small stacks there had been an issue.) This also is
331tidier for JIT matching, which didn't need that vector. The heap vector is now
332remembered in the match data block and re-used if that block itself is re-used.
333It is freed with the match data block.
334
33510. Adjusted the find_limits code in pcre2test to work with change 9 above.
336
33711. Added find_limits_noheap to pcre2test, because the heap limits are now
338different in different environments and so cannot be included in the standard
339tests.
340
34112. Created a test for pcre2_match() heap processing that is not part of the
342tests run by 'make check', but can be run manually. The current output is from
343a 64-bit system.
344
34513. Implemented -Z aka --null in pcre2grep.
346
34714. A minor change to pcre2test and the addition of several new pcre2grep tests
348have improved LCOV coverage statistics. At the same time, code in pcre2grep and
349elsewhere that can never be obeyed in normal testing has been excluded from
350coverage.
351
35215. Fixed a bug in pcre2grep that could cause an extra newline to be written
353after output generated by --output.
354
35516. If a file has a .bz2 extension but is not in fact compressed, pcre2grep
356should process it as a plain text file. A bug stopped this happening; now fixed
357and added to the tests.
358
35917. When pcre2grep was running not in UTF mode, if a string specified by
360--output or obtained from a callout in a pattern contained a character (byte)
361greater than 127, it was incorrectly output in UTF-8 format.
362
36318. Added some casts after warnings from Clang sanitize.
364
36519. Merged patch from cbouc (GitHub #139): 4 function prototypes were missing
366PCRE2_CALL_CONVENTION in src/pcre2posix.h. All function prototypes returning
367pointers had out of place PCRE2_CALL_CONVENTION in src/pcre2.h.*. These
368produced errors when building for Windows with #define PCRE2_CALL_CONVENTION
369__stdcall.
370
37120. A negative repeat value in a pcre2test subject line was not being
372diagnosed, leading to infinite looping.
373
37421. Updated RunGrepTest to discard the warning that Bash now gives when setting
375LC_CTYPE to a bad value (because older versions didn't).
376
37722. Updated pcre2grep so that it behaves like GNU grep when matching more than
378one pattern and a later pattern matches at an earlier point in the subject when
379the matched substrings are being identified by colour or by offsets.
380
38123. Updated the PrepareRelease script so that the man page that it makes for
382the pcre2demo demonstration program is more standard and does not cause errors
383when processed by lexgrog or mandb -c (GitHub issue #160).
384
38524. The JIT compiler was updated.
386
387
388Version 10.40 15-April-2022
389---------------------------
390
3911. Merged patch from @carenas (GitHub #35, 7db87842) to fix pcre2grep incorrect
392handling of multiple passes.
393
3942. Merged patch from @carenas (GitHub #36, dae47509) to fix portability issue
395in pcre2grep with buffered fseek(stdin).
396
3973. Merged patch from @carenas (GitHub #37, acc520924) to fix tests when -S is
398not supported.
399
4004. Revert an unintended change in JIT repeat detection.
401
4025. Merged patch from @carenas (GitHub #52, b037bfa1) to fix build on GNU Hurd.
403
4046. Merged documentation and comments patches from @carenas (GitHub #47).
405
4067. Merged patch from @carenas (GitHub #49) to remove obsolete JFriedl test code
407from pcre2grep.
408
4098. Merged patch from @carenas (GitHub #48) to fix CMake install issue #46.
410
4119. Merged patch from @carenas (GitHub #53) fixing NULL checks in matching and
412substituting.
413
41410. Add null_subject and null_replacement modifiers to pcre2test.
415
41611. Add check for NULL subject to POSIX regexec() function.
417
41812. Add check for NULL replacement to pcre2_substitute().
419
42013. For the subject arguments of pcre2_match(), pcre2_dfa_match(), and
421pcre2_substitute(), and the replacement argument of the latter, if the pointer
422is NULL and the length is zero, treat as an empty string. Apparently a number
423of applications treat NULL/0 in this way.
424
42514. Added support for Bidi_Class and a number of binary Unicode properties,
426including Bidi_Control.
427
42815. Fix some minor issues raised by clang sanitize.
429
43016. Very minor code speed up for maximizing character property matches.
431
43217. A number of changes to script matching for \p and \P:
433
434    (a) Script extensions for a character are now coded as a bitmap instead of
435        a list of script numbers, which should be faster and does not need a
436        loop.
437
438    (b) Added the syntax \p{script:xxx} and \p{script_extensions:xxx} (synonyms
439        sc and scx).
440
441    (c) Changed \p{scriptname} from being the same as \p{sc:scriptname} to being
442        the same as \p{scx:scriptname} because this change happened in Perl at
443        release 5.26.
444
445    (d) The standard Unicode 4-letter abbreviations for script names are now
446        recognized.
447
448    (e) In accordance with Unicode and Perl's "loose matching" rules, spaces,
449        hyphens, and underscores are ignored in property names, which are then
450        matched independent of case.
451
45218. The Python scripts in the maint directory have been refactored. There are
453now three scripts that generate pcre2_ucd.c, pcre2_ucp.h, and pcre2_ucptables.c
454(which is #included by pcre2_tables.c). The data lists that used to be
455duplicated are now held in a single common Python module.
456
45719. On CHERI, and thus Arm's Morello prototype, pointers are represented as
458hardware capabilities, which consist of both an integer address and additional
459metadata, meaning they are twice the size of the platform's size_t type, i.e.
46016 bytes on a 64-bit system. The ovector member of heapframe happens to only be
4618 byte aligned, and so computing frame_size ended up with a multiple of 8 but
462not 16. Whilst the first frame was always suitably aligned, this then
463misaligned the frame that follows, resulting in an alignment fault when storing
464a pointer to Fecode at the start of match. Patch to fix this issue by Jessica
465Clarke PR#72.
466
46720. Added -LP and -LS listing options to pcre2test.
468
46921. A user discovered that the library names in CMakeLists.txt for MSVC
470debugger (PDB) files were incorrect - perhaps never tried for PCRE2?
471
47222. An item such as [Aa] is optimized into a caseless single character match.
473When this was quantified (e.g. [Aa]{2}) and was also the last literal item in a
474pattern, the optimizing "must be present for a match" character check was not
475being flagged as caseless, causing some matches that should have succeeded to
476fail.
477
47823. Fixed a unicode property matching issue in JIT. The character was not
479fully read in caseless matching.
480
48124. Fixed an issue affecting recursions in JIT caused by duplicated data
482transfers.
483
48425. Merged patch from @carenas (GitHub #96) which fixes some problems with
485pcre2test and readline/readedit:
486
487  * Use the right header for libedit in FreeBSD with autoconf
488  * Really allow libedit with cmake
489  * Avoid using readline headers with libedit
490
491
492Version 10.39 29-October-2021
493-----------------------------
494
4951. Fix incorrect detection of alternatives in first character search in JIT.
496
4972. Merged patch from @carenas (GitHub #28):
498
499  Visual Studio 2013 includes support for %zu and %td, so let newer
500  versions of it avoid the fallback, and while at it, make sure that
501  the first check is for DISABLE_PERCENT_ZT so it will be always
502  honoured if chosen.
503
504  prtdiff_t is signed, so use a signed type instead, and make sure
505  that an appropriate width is chosen if pointers are 64bit wide and
506  long is not (ex: Windows 64bit).
507
508  IMHO removing the cast (and therefore the possibility of truncation)
509  make the code cleaner and the fallback is likely portable enough
510  with all 64-bit POSIX systems doing LP64 except for Windows.
511
5123. Merged patch from @carenas (GitHub #29) to update to Unicode 14.0.0.
513
5144. Merged patch from @carenas (GitHub #30):
515
516  * Cleanup: remove references to no longer used stdint.h
517
518  Since 19c50b9d (Unconditionally use inttypes.h instead of trying for stdint.h
519  (simplification) and remove the now unnecessary inclusion in
520  pcre2_internal.h., 2018-11-14), stdint.h is no longer used.
521
522  Remove checks for it in autotools and CMake and document better the expected
523  build failures for systems that might have stdint.h (C99) and not inttypes.h
524  (from POSIX), like old Windows.
525
526  * Cleanup: remove detection for inttypes.h which is a hard dependency
527
528  CMake checks for standard headers are not meant to be used for hard
529  dependencies, so will prevent a possible fallback to work.
530
531  Alternatively, the header could be checked to make the configuration fail
532  instead of breaking the build, but that was punted, as it was missing anyway
533  from autotools.
534
5355. Merged patch from @carenas (GitHub #32):
536
537  * jit: allow building with ancient MSVC versions
538
539  Visual Studio older than 2013 fails to build with JIT enabled, because it is
540  unable to parse non C89 compatible syntax, with mixed declarations and code.
541  While most recent compilers wouldn't even report this as a warning since it
542  is valid C99, it could be also made visible by adding to gcc/clang the
543  -Wdeclaration-after-statement flag at build time.
544
545  Move the code below the affected definitions.
546
547  * pcre2grep: avoid mixing declarations with code
548
549  Since d5a61ee8 (Patch to detect (and ignore) symlink loops in pcre2grep,
550  2021-08-28), code will fail to build in a strict C89 compiler.
551
552  Reformat slightly to make it C89 compatible again.
553
554
555Version 10.38 01-October-2021
556-----------------------------
557
5581. Fix invalid single character repetition issues in JIT when the repetition
559is inside a capturing bracket and the bracket is preceded by character
560literals.
561
5622. Installed revised CMake configuration files provided by Jan-Willem Blokland.
563This extends the CMake build system to build both static and shared libraries
564in one go, builds the static library with PIC, and exposes PCRE2 libraries
565using the CMake config files. JWB provided these notes:
566
567- Introduced CMake variable BUILD_STATIC_LIBS to build the static library.
568
569- Make a small modification to config-cmake.h.in by removing the PCRE2_STATIC
570  variable. Added PCRE2_STATIC variable to the static build using the
571  target_compile_definitions() function.
572
573- Extended the CMake config files.
574
575  - Introduced CMake variable PCRE2_USE_STATIC_LIBS to easily switch between
576    the static and shared libraries.
577
578  - Added the PCRE_STATIC variable to the target compile definitions for the
579    import of the static library.
580
581Building static and shared libraries using MSVC results in a name clash of
582the libraries. Both static and shared library builds create, for example, the
583file pcre2-8.lib. Therefore, I decided to change the static library names by
584adding "-static". For example, pcre2-8.lib has become pcre2-8-static.lib.
585[Comment by PH: this is MSVC-specific. It doesn't happen on Linux.]
586
5873. Increased the minimum release number for CMake to 3.0.0 because older than
5882.8.12 is deprecated (it was set to 2.8.5) and causes warnings. Even 3.0.0 is
589quite old; it was released in 2014.
590
5914. Implemented a modified version of Thomas Tempelmann's pcre2grep patch for
592detecting symlink loops. This is dependent on the availability of realpath(),
593which is now tested for in ./configure and CMakeLists.txt.
594
5955. Implemented a modified version of Thomas Tempelmann's patch for faster
596case-independent "first code unit" searches for unanchored patterns in 8-bit
597mode in the interpreters. Instead of just remembering whether one case matched
598or not, it remembers the position of a previous match so as to avoid
599unnecessary repeated searching.
600
6016. Perl now locks out \K in lookarounds, so PCRE2 now does the same by default.
602However, just in case anybody was relying on the old behaviour, there is an
603option called PCRE2_EXTRA_ALLOW_LOOKAROUND_BSK that enables the old behaviour.
604An option has also been added to pcre2grep to enable this.
605
6067. Re-enable a JIT optimization which was unintentionally disabled in 10.35.
607
6088. There is a loop counter to catch excessively crazy patterns when checking
609the lengths of lookbehinds at compile time. This was incorrectly getting reset
610whenever a lookahead was processed, leading to some fuzzer-generated patterns
611taking a very long time to compile when (?|) was present in the pattern,
612because (?|) disables caching of group lengths.
613
614
615Version 10.37 26-May-2021
616-------------------------
617
6181. Change RunGrepTest to use tr instead of sed when testing with binary
619zero bytes, because sed varies a lot from system to system and has problems
620with binary zeros. This is from Bugzilla #2681. Patch from Jeremie
621Courreges-Anglas via Nam Nguyen. This fixes RunGrepTest for OpenBSD. Later:
622it broke it for at least one version of Solaris, where tr can't handle binary
623zeros. However, that system had /usr/xpg4/bin/tr installed, which works OK, so
624RunGrepTest now checks for that command and uses it if found.
625
6262. Compiling with gcc 10.2's -fanalyzer option showed up a hypothetical problem
627with a NULL dereference. I don't think this case could ever occur in practice,
628but I have put in a check in order to get rid of the compiler error.
629
6303. An alternative patch for CMakeLists.txt because 10.36 #4 breaks CMake on
631Windows. Patch from [email protected] fixes bugzilla #2688.
632
6334. Two bugs related to over-large numbers have been fixed so the behaviour is
634now the same as Perl.
635
636  (a) A pattern such as /\214748364/ gave an overflow error instead of being
637  treated as the octal number \214 followed by literal digits.
638
639  (b) A sequence such as {65536 that has no terminating } so is not a
640  quantifier was nevertheless complaining that a quantifier number was too big.
641
6425. A run of autoconf suggested that configure.ac was out-of-date with respect
643to the latest autoconf. Running autoupdate made some valid changes, some valid
644suggestions, and also some invalid changes, which were fixed by hand. Autoconf
645now runs clean and the resulting "configure" seems to work, so I hope nothing
646is broken. Later: the requirement for autoconf 2.70 broke some automatic test
647robots. It doesn't seem to be necessary: trying a reduction to 2.60.
648
6496. The pattern /a\K.(?0)*/ when matched against "abac" by the interpreter gave
650the answer "bac", whereas Perl and JIT both yield "c". This was because the
651effect of \K was not propagating back from the full pattern recursion. Other
652recursions such as /(a\K.(?1)*)/ did not have this problem.
653
6547. Restore single character repetition optimization in JIT. Currently fewer
655character repetitions are optimized than in 10.34.
656
6578. When the names of the functions in the POSIX wrapper were changed to
658pcre2_regcomp() etc. (see change 10.33 #4 below), functions with the original
659names were left in the library so that pre-compiled programs would still work.
660However, this has proved troublesome when programs link with several libraries,
661some of which use PCRE2 via the POSIX interface while others use a native POSIX
662library. For this reason, the POSIX function names are removed in this release.
663The macros in pcre2posix.h should ensure that re-compiling fixes any programs
664that haven't been compiled since before 10.33.
665
666
667Version 10.36 04-December-2020
668------------------------------
669
6701. Add CET_CFLAGS so that when Intel CET is enabled, pass -mshstk to
671compiler. This fixes https://bugs.exim.org/show_bug.cgi?id=2578. Patch for
672Makefile.am and configure.ac by H.J. Lu. Equivalent patch for CMakeLists.txt
673invented by PH.
674
6752. Fix infinite loop when a single byte newline is searched in JIT when
676invalid utf8 mode is enabled.
677
6783. Updated CMakeLists.txt with patch from Wolfgang Stöggl (Bugzilla #2584):
679
680  - Include GNUInstallDirs and use ${CMAKE_INSTALL_LIBDIR} instead of hardcoded
681    lib. This allows differentiation between lib and lib64.
682    CMAKE_INSTALL_LIBDIR is used for installation of libraries and also for
683    pkgconfig file generation.
684
685  - Add the version of PCRE2 to the configuration summary like ./configure
686    does.
687
688  - Fix typo: MACTHED_STRING->MATCHED_STRING
689
6904. Updated CMakeLists.txt with another patch from Wolfgang Stöggl (Bugzilla
691#2588):
692
693  - Add escaped double quotes around include directory in CMakeLists.txt to
694    allow spaces in directory names.
695
696  - This fixes a cmake error, if the path of the pcre2 source contains a space.
697
6985. Updated CMakeLists.txt with a patch from B. Scott Michel: CMake's
699documentation suggests using CHECK_SYMBOL_EXISTS over CHECK_FUNCTION_EXIST.
700Moreover, these functions come from specific header files, which need to be
701specified (and, thankfully, are the same on both the Linux and WinXX
702platforms.)
703
7046. Added a (uint32_t) cast to prevent a compiler warning in pcre2_compile.c.
705
7067. Applied a patch from Wolfgang Stöggl (Bugzilla #2600) to fix postfix for
707debug Windows builds using CMake. This also updated configure so that it
708generates *.pc files and pcre2-config with the same content, as in the past.
709
7108. If a pattern ended with (?(VERSION=n.d where n is any number but d is just a
711single digit, the code unit beyond d was being read (i.e. there was a read
712buffer overflow). Fixes ClusterFuzz 23779.
713
7149. After the rework in r1235, certain character ranges were incorrectly
715handled by an optimization in JIT. Furthermore a wrong offset was used to
716read a value from a buffer which could lead to memory overread.
717
71810. Unnoticed for many years was the fact that delimiters other than / in the
719testinput1 and testinput4 files could cause incorrect behaviour when these
720files were processed by perltest.sh. There were several tests that used quotes
721as delimiters, and it was just luck that they didn't go wrong with perltest.sh.
722All the patterns in testinput1 and testinput4 now use / as their delimiter.
723This fixes Bugzilla #2641.
724
72511. Perl has started to give an error for \K within lookarounds (though there
726are cases where it doesn't). PCRE2 still allows this, so the tests that include
727this case have been moved from test 1 to test 2.
728
72912. Further to 10 above, pcre2test has been updated to detect and grumble if a
730delimiter other than / is used after #perltest.
731
73213. Fixed a bug with PCRE2_MATCH_INVALID_UTF in 8-bit mode when PCRE2_CASELESS
733was set and PCRE2_NO_START_OPTIMIZE was not set. The optimization for finding
734the start of a match was not resetting correctly after a failed match on the
735first valid fragment of the subject, possibly causing incorrect "no match"
736returns on subsequent fragments. For example, the pattern /A/ failed to match
737the subject \xe5A. Fixes Bugzilla #2642.
738
73914. Fixed a bug in character set matching when JIT is enabled and both unicode
740scripts and unicode classes are present at the same time.
741
74215. Added GNU grep's -m (aka --max-count) option to pcre2grep.
743
74416. Refactored substitution processing in pcre2grep strings, both for the -O
745option and when dealing with callouts. There is now a single function that
746handles $ expansion in all cases (instead of multiple copies of almost
747identical code). This means that the same escape sequences are available
748everywhere, which was not previously the case. At the same time, the escape
749sequences $x{...} and $o{...} have been introduced, to allow for characters
750whose code points are greater than 255 in Unicode mode.
751
75217. Applied the patch from Bugzilla #2628 to RunGrepTest. This does an explicit
753test for a version of sed that can handle binary zero, instead of assuming that
754any Linux version will work. Later: replaced $(...) by `...` because not all
755shells recognize the former.
756
75718. Fixed a word boundary check bug in JIT when partial matching is enabled.
758
75919. Fix ARM64 compilation warning in JIT. Patch by Carlo.
760
76120. A bug in the RunTest script meant that if the first part of test 2 failed,
762the failure was not reported.
763
76421. Test 2 was failing when run from a directory other than the source
765directory. This failure was previously missed in RunTest because of 20 above.
766Fixes added to both RunTest and RunTest.bat.
767
76822. Patch to CMakeLists.txt from Daniel to fix problem with testing under
769Windows.
770
771
772Version 10.35 09-May-2020
773---------------------------
774
7751. Use PCRE2_MATCH_EMPTY flag to detect empty matches in JIT.
776
7772. Fix ARMv5 JIT improper handling of labels right after a constant pool.
778
7793. A JIT bug is fixed which allowed to read the fields of the compiled
780pattern before its existence is checked.
781
7824. Back in the PCRE1 day, capturing groups that contained recursive back
783references to themselves were made atomic (version 8.01, change 18) because
784after the end a repeated group, the captured substrings had their values from
785the final repetition, not from an earlier repetition that might be the
786destination of a backtrack. This feature was documented, and was carried over
787into PCRE2. However, it has now been realized that the major refactoring that
788was done for 10.30 has made this atomizing unnecessary, and it is confusing
789when users are unaware of it, making some patterns appear not to be working as
790expected. Capture values of recursive back references in repeated groups are
791now correctly backtracked, so this unnecessary restriction has been removed.
792
7935. Added PCRE2_SUBSTITUTE_LITERAL.
794
7956. Avoid some VS compiler warnings.
796
7977. Added PCRE2_SUBSTITUTE_MATCHED.
798
7998. Added (?* and (?<* as synonyms for (*napla: and (*naplb: to match another
800regex engine. The Perl regex folks are aware of this usage and have made a note
801about it.
802
8039. When an assertion is repeated, PCRE2 used to limit the maximum repetition to
8041, believing that repeating an assertion is pointless. However, if a positive
805assertion contains capturing groups, repetition can be useful. In any case, an
806assertion could always be wrapped in a repeated group. The only restriction
807that is now imposed is that an unlimited maximum is changed to one more than
808the minimum.
809
81010. Fix *THEN verbs in lookahead assertions in JIT.
811
81211. Added PCRE2_SUBSTITUTE_REPLACEMENT_ONLY.
813
81412. The JIT stack should be freed when the low-level stack allocation fails.
815
81613. In pcre2grep, if the final line in a scanned file is output but does not
817end with a newline sequence, add a newline according to the --newline setting.
818
81914. (?(DEFINE)...) groups were not being handled correctly when checking for
820the fixed length of a lookbehind assertion. Such a group within a lookbehind
821should be skipped, as it does not contribute to the length of the group.
822Instead, the (DEFINE) group was being processed, and if at the end of the
823lookbehind, that end was not correctly recognized. Errors such as "lookbehind
824assertion is not fixed length" and also "internal error: bad code value in
825parsed_skip()" could result.
826
82715. Put a limit of 1000 on recursive calls in pcre2_study() when searching
828nested groups for starting code units, in order to avoid stack overflow issues.
829If the limit is reached, it just gives up trying for this optimization.
830
83116. The control verb chain list must always be restored when exiting from a
832recurse function in JIT.
833
83417. Fix a crash which occurs when the character type of an invalid UTF
835character is decoded in JIT.
836
83718. Changes in many areas of the code so that when Unicode is supported and
838PCRE2_UCP is set without PCRE2_UTF, Unicode character properties are used for
839upper/lower case computations on characters whose code points are greater than
840127.
841
84219. The function for checking UTF-16 validity was returning an incorrect offset
843for the start of the error when a high surrogate was not followed by a valid
844low surrogate. This caused incorrect behaviour, for example when
845PCRE2_MATCH_INVALID_UTF was set and a match started immediately following the
846invalid high surrogate, such as /aa/ matching "\x{d800}aa".
847
84820. If a DEFINE group immediately preceded a lookbehind assertion, the pattern
849could be mis-compiled and therefore not match correctly. This is the example
850that found this: /(?(DEFINE)(?<foo>bar))(?<![-a-z0-9])word/ which failed to
851match "word" because the "move back" value was set to zero.
852
85321. Following a request from a user, some extensions and tidies to the
854character tables handling have been done:
855
856  (a) The dftables auxiliary program is renamed pcre2_dftables, but it is still
857  not installed for public use.
858
859  (b) There is now a -b option for pcre2_dftables, which causes the tables to
860  be written in binary. There is also a -help option.
861
862  (c) PCRE2_CONFIG_TABLES_LENGTH is added to pcre2_config() so that an
863  application that wants to save tables in binary knows how long they are.
864
86522. Changed setting of CMAKE_MODULE_PATH in CMakeLists.txt from SET to
866LIST(APPEND...) to allow a setting from the command line to be included.
867
86823. Updated to Unicode 13.0.0.
869
87024. CMake build now checks for secure_getenv() and strerror(). Patch by Carlo.
871
87225. Avoid using [-1] as a suffix in pcre2test because it can provoke a compiler
873warning.
874
87526. Added tests for __attribute__((uninitialized)) to both the configure and
876CMake build files, and then applied this attribute to the variable called
877stack_frames_vector[] in pcre2_match(). When implemented, this disables
878automatic initialization (a facility in clang), which can take time on big
879variables.
880
88127. Updated CMakeLists.txt (patches by Uwe Korn) to add support for
882pcre2-config, the libpcre*.pc files, SOVERSION, VERSION and the
883MACHO_*_VERSIONS settings for CMake builds.
884
88528. Another patch to CMakeLists.txt to check for mkostemp (configure already
886does). Patch by Carlo Marcelo Arenas Belon.
887
88829. Check for the existence of memfd_create in both CMake and configure
889configurations. Patch by Carlo Marcelo Arenas Belon.
890
89130. Restrict the configuration setting for the SELinux compatible execmem
892allocator (change 10.30/44) to Linux and NetBSD.
893
894
895Version 10.34 21-November-2019
896------------------------------
897
8981. The maximum number of capturing subpatterns is 65535 (documented), but no
899check on this was ever implemented. This omission has been rectified; it fixes
900ClusterFuzz 14376.
901
9022. Improved the invalid utf32 support of the JIT compiler. Now it correctly
903detects invalid characters in the 0xd800-0xdfff range.
904
9053. Fix minor typo bug in JIT compile when \X is used in a non-UTF string.
906
9074. Add support for matching in invalid UTF strings to the pcre2_match()
908interpreter, and integrate with the existing JIT support via the new
909PCRE2_MATCH_INVALID_UTF compile-time option.
910
9115. Give more error detail for invalid UTF-8 when detected in pcre2grep.
912
9136. Add support for invalid UTF-8 to pcre2grep.
914
9157. Adjust the limit for "must have" code unit searching, in particular,
916increase it substantially for non-anchored patterns.
917
9188. Allow (*ACCEPT) to be quantified, because an ungreedy quantifier with a zero
919minimum is potentially useful.
920
9219. Some changes to the way the minimum subject length is handled:
922
923   * When PCRE2_NO_START_OPTIMIZE is set, no minimum length is computed;
924     pcre2test now omits this item instead of showing a value of zero.
925
926   * An incorrect minimum length could be calculated for a pattern that
927     contained (*ACCEPT) inside a qualified group whose minimum repetition was
928     zero, for example /A(?:(*ACCEPT))?B/, which incorrectly computed a minimum
929     of 2. The minimum length scan no longer happens for a pattern that
930     contains (*ACCEPT).
931
932   * When no minimum length is set by the normal scan, but a first and/or last
933     code unit is recorded, set the minimum to 1 or 2 as appropriate.
934
935   * When a pattern contains multiple groups with the same number, a back
936     reference cannot know which one to scan for a minimum length. This used to
937     cause the minimum length finder to give up with no result. Now it treats
938     such references as not adding to the minimum length (which it should have
939     done all along).
940
941   * Furthermore, the above action now happens only if the back reference is to
942     a group that exists more than once in a pattern instead of any back
943     reference in a pattern with duplicate numbers.
944
94510. A (*MARK) value inside a successful condition was not being returned by the
946interpretive matcher (it was returned by JIT). This bug has been mended.
947
94811. A bug in pcre2grep meant that -o without an argument (or -o0) didn't work
949if the pattern had more than 32 capturing parentheses. This is fixed. In
950addition (a) the default limit for groups requested by -o<n> has been raised to
95150, (b) the new --om-capture option changes the limit, (c) an error is raised
952if -o asks for a group that is above the limit.
953
95412. The quantifier {1} was always being ignored, but this is incorrect when it
955is made possessive and applied to an item in parentheses, because a
956parenthesized item may contain multiple branches or other backtracking points,
957for example /(a|ab){1}+c/ or /(a+){1}+a/.
958
95913. For partial matches, pcre2test was always showing the maximum lookbehind
960characters, flagged with "<", which is misleading when the lookbehind didn't
961actually look behind the start (because it was later in the pattern). Showing
962all consulted preceding characters for partial matches is now controlled by the
963existing "allusedtext" modifier and, as for complete matches, this facility is
964available only for non-JIT matching, because JIT does not maintain the first
965and last consulted characters.
966
96714. DFA matching (using pcre2_dfa_match()) was not recognising a partial match
968if the end of the subject was encountered in a lookahead (conditional or
969otherwise), an atomic group, or a recursion.
970
97115. Give error if pcre2test -t, -T, -tm or -TM is given an argument of zero.
972
97316. Check for integer overflow when computing lookbehind lengths. Fixes
974Clusterfuzz issue 15636.
975
97617. Implemented non-atomic positive lookaround assertions.
977
97818. If a lookbehind contained a lookahead that contained another lookbehind
979within it, the nested lookbehind was not correctly processed. For example, if
980/(?<=(?=(?<=a)))b/ was matched to "ab" it gave no match instead of matching
981"b".
982
98319. Implemented pcre2_get_match_data_size().
984
98520. Two alterations to partial matching:
986
987    (a) The definition of a partial match is slightly changed: if a pattern
988    contains any lookbehinds, an empty partial match may be given, because this
989    is another situation where adding characters to the current subject can
990    lead to a full match. Example: /c*+(?<=[bc])/ with subject "ab".
991
992    (b) Similarly, if a pattern could match an empty string, an empty partial
993    match may be given. Example: /(?![ab]).*/ with subject "ab". This case
994    applies only to PCRE2_PARTIAL_HARD.
995
996    (c) An empty string partial hard match can be returned for \z and \Z as it
997    is documented that they shouldn't match.
998
99921. A branch that started with (*ACCEPT) was not being recognized as one that
1000could match an empty string.
1001
100222. Corrected pcre2_set_character_tables() tables data type: was const unsigned
1003char * instead of const uint8_t *, as generated by pcre2_maketables().
1004
100523. Upgraded to Unicode 12.1.0.
1006
100724. Add -jitfast command line option to pcre2test (to make all the jit options
1008available directly).
1009
101025. Make pcre2test -C show if libreadline or libedit is supported.
1011
101226. If the length of one branch of a group exceeded 65535 (the maximum value
1013that is remembered as a minimum length), the whole group's length was
1014incorrectly recorded as 65535, leading to incorrect "no match" when start-up
1015optimizations were in force.
1016
101727. The "rightmost consulted character" value was not always correct; in
1018particular, if a pattern ended with a negative lookahead, characters that were
1019inspected in that lookahead were not included.
1020
102128. Add the pcre2_maketables_free() function.
1022
102329. The start-up optimization that looks for a unique initial matching
1024code unit in the interpretive engines uses memchr() in 8-bit mode. When the
1025search is caseless, it was doing so inefficiently, which ended up slowing down
1026the match drastically when the subject was very long. The revised code (a)
1027remembers if one case is not found, so it never repeats the search for that
1028case after a bumpalong and (b) when one case has been found, it searches only
1029up to that position for an earlier occurrence of the other case. This fix
1030applies to both interpretive pcre2_match() and to pcre2_dfa_match().
1031
103230. While scanning to find the minimum length of a group, if any branch has
1033minimum length zero, there is no need to scan any subsequent branches (a small
1034compile-time performance improvement).
1035
103631. Installed a .gitignore file on a user's suggestion. When using the svn
1037repository with git (through git svn) this helps keep it tidy.
1038
103932. Add underflow check in JIT which may occur when the value of subject
1040string pointer is close to 0.
1041
104233. Arrange for classes such as [Aa] which contain just the two cases of the
1043same character, to be treated as a single caseless character. This causes the
1044first and required code unit optimizations to kick in where relevant.
1045
104634. Improve the bitmap of starting bytes for positive classes that include wide
1047characters, but no property types, in UTF-8 mode. Previously, on encountering
1048such a class, the bits for all bytes greater than \xc4 were set, thus
1049specifying any character with codepoint >= 0x100. Now the only bits that are
1050set are for the relevant bytes that start the wide characters. This can give a
1051noticeable performance improvement.
1052
105335. If the bitmap of starting code units contains only 1 or 2 bits, replace it
1054with a single starting code unit (1 bit) or a caseless single starting code
1055unit if the two relevant characters are case-partners. This is particularly
1056relevant to the 8-bit library, though it applies to all. It can give a
1057performance boost for patterns such as [Ww]ord and (word|WORD). However, this
1058optimization doesn't happen if there is a "required" code unit of the same
1059value (because the search for a "required" code unit starts at the match start
1060for non-unique first code unit patterns, but after a unique first code unit,
1061and patterns such as a*a need the former action).
1062
106336. Small patch to pcre2posix.c to set the erroroffset field to -1 immediately
1064after a successful compile, instead of at the start of matching to avoid a
1065sanitizer complaint (regexec is supposed to be thread safe).
1066
106737. Add NEON vectorization to JIT to speed up matching of first character and
1068pairs of characters on ARM64 CPUs.
1069
107038. If a non-ASCII character was the first in a starting assertion in a
1071caseless match, the "first code unit" optimization did not get the casing
1072right, and the assertion failed to match a character in the other case if it
1073did not start with the same code unit.
1074
107539. Fixed the incorrect computation of jump sizes on x86 CPUs in JIT. A masking
1076operation was incorrectly removed in r1136. Reported by Ralf Junker.
1077
1078
1079Version 10.33 16-April-2019
1080---------------------------
1081
10821. Added "allvector" to pcre2test to make it easy to check the part of the
1083ovector that shouldn't be changed, in particular after substitute and failed or
1084partial matches.
1085
10862. Fix subject buffer overread in JIT when UTF is disabled and \X or \R has
1087a greater than 1 fixed quantifier. This issue was found by Yunho Kim.
1088
10893. Added support for callouts from pcre2_substitute(). After 10.33-RC1, but
1090prior to release, fixed a bug that caused a crash if pcre2_substitute() was
1091called with a NULL match context.
1092
10934. The POSIX functions are now all called pcre2_regcomp() etc., with wrapper
1094functions that use the standard POSIX names. However, in pcre2posix.h the POSIX
1095names are defined as macros. This should help avoid linking with the wrong
1096library in some environments while still exporting the POSIX names for
1097pre-existing programs that use them. (The Debian alternative names are also
1098defined as macros, but not documented.)
1099
11005. Fix an xclass matching issue in JIT.
1101
11026. Implement PCRE2_EXTRA_ESCAPED_CR_IS_LF (see Bugzilla 2315).
1103
11047. Implement the Perl 5.28 experimental alphabetic names for atomic groups and
1105lookaround assertions, for example, (*pla:...) and (*atomic:...). These are
1106characterized by a lower case letter following (* and to simplify coding for
1107this, the character tables created by pcre2_maketables() were updated to add a
1108new "is lower case letter" bit. At the same time, the now unused "is
1109hexadecimal digit" bit was removed. The default tables in
1110src/pcre2_chartables.c.dist are updated.
1111
11128. Implement the new Perl "script run" features (*script_run:...) and
1113(*atomic_script_run:...) aka (*sr:...) and (*asr:...).
1114
11159. Fixed two typos in change 22 for 10.21, which added special handling for
1116ranges such as a-z in EBCDIC environments. The original code probably never
1117worked, though there were no bug reports.
1118
111910. Implement PCRE2_COPY_MATCHED_SUBJECT for pcre2_match() (including JIT via
1120pcre2_match()) and pcre2_dfa_match(), but *not* the pcre2_jit_match() fast
1121path. Also, when a match fails, set the subject field in the match data to NULL
1122for tidiness - none of the substring extractors should reference this after
1123match failure.
1124
112511. If a pattern started with a subroutine call that had a quantifier with a
1126minimum of zero, an incorrect "match must start with this character" could be
1127recorded. Example: /(?&xxx)*ABC(?<xxx>XYZ)/ would (incorrectly) expect 'A' to
1128be the first character of a match.
1129
113012. The heap limit checking code in pcre2_dfa_match() could suffer from
1131overflow if the heap limit was set very large. This could cause incorrect "heap
1132limit exceeded" errors.
1133
113413. Add "kibibytes" to the heap limit output from pcre2test -C to make the
1135units clear.
1136
113714. Add a call to pcre2_jit_free_unused_memory() in pcre2grep, for tidiness.
1138
113915. Updated the VMS-specific code in pcre2test on the advice of a VMS user.
1140
114116. Removed the unnecessary inclusion of stdint.h (or inttypes.h) from
1142pcre2_internal.h as it is now included by pcre2.h. Also, change 17 for 10.32
1143below was unnecessarily complicated, as inttypes.h is a Standard C header,
1144which is defined to be a superset of stdint.h. Instead of conditionally
1145including stdint.h or inttypes.h, pcre2.h now unconditionally includes
1146inttypes.h. This supports environments that do not have stdint.h but do have
1147inttypes.h, which are known to exist. A note in the autotools documentation
1148says (November 2018) that there are none known that are the other way round.
1149
115017. Added --disable-percent-zt to "configure" (and equivalent to CMake) to
1151forcibly disable the use of %zu and %td in formatting strings because there is
1152at least one version of VMS that claims to be C99 but does not support these
1153modifiers.
1154
115518. Added --disable-pcre2grep-callout-fork, which restricts the callout support
1156in pcre2grep to the inbuilt echo facility. This may be useful in environments
1157that do not support fork().
1158
115919. Fix two instances of <= 0 being applied to unsigned integers (the VMS
1160compiler complains).
1161
116220. Added "fork" support for VMS to pcre2grep, for running an external program
1163via a string callout.
1164
116521. Improve MAP_JIT flag usage on MacOS. Patch by Rich Siegel.
1166
116722. If a pattern started with (*MARK), (*COMMIT), (*PRUNE), (*SKIP), or (*THEN)
1168followed by ^ it was not recognized as anchored.
1169
117023. The RunGrepTest script used to cut out the test of NUL characters for
1171Solaris and MacOS as printf and sed can't handle them. It seems that the *BSD
1172systems can't either. I've inverted the test so that only those OS that are
1173known to work (currently only Linux) try to run this test.
1174
117524. Some tests in RunGrepTest appended to testtrygrep from two different file
1176descriptors instead of redirecting stderr to stdout. This worked on Linux, but
1177it was reported not to on other systems, causing the tests to fail.
1178
117925. In the RunTest script, make the test for stack setting use the same value
1180for the stack as it needs for -bigstack.
1181
118226. Insert a cast in pcre2_dfa_match.c to suppress a compiler warning.
1183
118426. With PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL set, escape sequences such as \s
1185which are valid in character classes, but not as the end of ranges, were being
1186treated as literals. An example is [_-\s] (but not [\s-_] because that gave an
1187error at the *start* of a range). Now an "invalid range" error is given
1188independently of PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL.
1189
119027. Related to 26 above, PCRE2_BAD_ESCAPE_IS_LITERAL was affecting known escape
1191sequences such as \eX when they appeared invalidly in a character class. Now
1192the option applies only to unrecognized or malformed escape sequences.
1193
119428. Fix word boundary in JIT compiler. Patch by Mike Munday.
1195
119629. The pcre2_dfa_match() function was incorrectly handling conditional version
1197tests such as (?(VERSION>=0)...) when the version test was true. Incorrect
1198processing or a crash could result.
1199
120030. When PCRE2_UTF is set, allow non-ASCII letters and decimal digits in group
1201names, as Perl does. There was a small bug in this new code, found by
1202ClusterFuzz 12950, fixed before release.
1203
120431. Implemented PCRE2_EXTRA_ALT_BSUX to support ECMAScript 6's \u{hhh}
1205construct.
1206
120732. Compile \p{Any} to be the same as . in DOTALL mode, so that it benefits
1208from auto-anchoring if \p{Any}* starts a pattern.
1209
121033. Compile invalid UTF check in JIT test when only pcre32 is enabled.
1211
121234. For some time now, CMake has been warning about the setting of policy
1213CMP0026 to "OLD" in CmakeLists.txt, and hinting that the feature might be
1214removed in a future version. A request for CMake expertise on the list produced
1215no result, so I have now hacked CMakeLists.txt along the lines of some changes
1216I found on the Internet. The new code no longer needs the policy setting, and
1217it appears to work fine on Linux.
1218
121935. Setting --enable-jit=auto for an out-of-tree build failed because the
1220source directory wasn't in the search path for AC_TRY_COMPILE always. Patch
1221from Ross Burton.
1222
122336. Disable SSE2 JIT optimizations in x86 CPUs when SSE2 is not available.
1224Patch by Guillem Jover.
1225
122637. Changed expressions such as 1<<10 to 1u<<10 in many places because compiler
1227warnings were reported.
1228
122938. Using the clang compiler with sanitizing options causes runtime complaints
1230about truncation for statements such as x = ~x when x is an 8-bit value; it
1231seems to compute ~x as a 32-bit value. Changing such statements to x = 255 ^ x
1232gets rid of the warnings. There were also two missing casts in pcre2test.
1233
1234
1235Version 10.32 10-September-2018
1236-------------------------------
1237
12381. When matching using the REG_STARTEND feature of the POSIX API with a
1239non-zero starting offset, unset capturing groups with lower numbers than a
1240group that did capture something were not being correctly returned as "unset"
1241(that is, with offset values of -1).
1242
12432. When matching using the POSIX API, pcre2test used to omit listing unset
1244groups altogether. Now it shows those that come before any actual captures as
1245"<unset>", as happens for non-POSIX matching.
1246
12473. Running "pcre2test -C" always stated "\R matches CR, LF, or CRLF only",
1248whatever the build configuration was. It now correctly says "\R matches all
1249Unicode newlines" in the default case when --enable-bsr-anycrlf has not been
1250specified. Similarly, running "pcre2test -C bsr" never produced the result
1251ANY.
1252
12534. Matching the pattern /(*UTF)\C[^\v]+\x80/ against an 8-bit string containing
1254multi-code-unit characters caused bad behaviour and possibly a crash. This
1255issue was fixed for other kinds of repeat in release 10.20 by change 19, but
1256repeating character classes were overlooked.
1257
12585. pcre2grep now supports the inclusion of binary zeros in patterns that are
1259read from files via the -f option.
1260
12616. A small fix to pcre2grep to avoid compiler warnings for -Wformat-overflow=2.
1262
12637. Added --enable-jit=auto support to configure.ac.
1264
12658. Added some dummy variables to the heapframe structure in 16-bit and 32-bit
1266modes for the benefit of m68k, where pointers can be 16-bit aligned. The
1267dummies force 32-bit alignment and this ensures that the structure is a
1268multiple of PCRE2_SIZE, a requirement that is tested at compile time. In other
1269architectures, alignment requirements take care of this automatically.
1270
12719. When returning an error from pcre2_pattern_convert(), ensure the error
1272offset is set zero for early errors.
1273
127410. A number of patches for Windows support from Daniel Richard G:
1275
1276  (a) List of error numbers in Runtest.bat corrected (it was not the same as in
1277      Runtest).
1278
1279  (b) pcre2grep snprintf() workaround as used elsewhere in the tree.
1280
1281  (c) Support for non-C99 snprintf() that returns -1 in the overflow case.
1282
128311. Minor tidy of pcre2_dfa_match() code.
1284
128512. Refactored pcre2_dfa_match() so that the internal recursive calls no longer
1286use the stack for local workspace and local ovectors. Instead, an initial block
1287of stack is reserved, but if this is insufficient, heap memory is used. The
1288heap limit parameter now applies to pcre2_dfa_match().
1289
129013. If a "find limits" test of DFA matching in pcre2test resulted in too many
1291matches for the ovector, no matches were displayed.
1292
129314. Removed an occurrence of ctrl/Z from test 6 because Windows treats it as
1294EOF. The test looks to have come from a fuzzer.
1295
129615. If PCRE2 was built with a default match limit a lot greater than the
1297default default of 10 000 000, some JIT tests of the match limit no longer
1298failed. All such tests now set 10 000 000 as the upper limit.
1299
130016. Another Windows related patch for pcregrep to ensure that WIN32 is
1301undefined under Cygwin.
1302
130317. Test for the presence of stdint.h and inttypes.h in configure and CMake and
1304include whichever exists (stdint preferred) instead of unconditionally
1305including stdint. This makes life easier for old and non-standard systems.
1306
130718. Further changes to improve portability, especially to old and or non-
1308standard systems:
1309
1310  (a) Put all printf arguments in RunGrepTest into single, not double, quotes,
1311      and use \0 not \x00 for binary zero.
1312
1313  (b) Avoid the use of C++ (i.e. BCPL) // comments.
1314
1315  (c) Parameterize the use of %zu in pcre2test to make it like %td. For both of
1316      these now, if using MSVC or a standard C before C99, %lu is used with a
1317      cast if necessary.
1318
131919. Applied a contributed patch to CMakeLists.txt to increase the stack size
1320when linking pcre2test with MSVC. This gets rid of a stack overflow error in
1321the standard set of tests.
1322
132320. Output a warning in pcre2test when ignoring the "altglobal" modifier when
1324it is given with the "replace" modifier.
1325
132621. In both pcre2test and pcre2_substitute(), with global matching, a pattern
1327that matched an empty string, but never at the starting match offset, was not
1328handled in a Perl-compatible way. The pattern /(<?=\G.)/ is an example of such
1329a pattern. Because \G is in a lookbehind assertion, there has to be a
1330"bumpalong" before there can be a match. The automatic "advance by one
1331character after an empty string match" rule is therefore inappropriate. A more
1332complicated algorithm has now been implemented.
1333
133422. When checking to see if a lookbehind is of fixed length, lookaheads were
1335correctly ignored, but qualifiers on lookaheads were not being ignored, leading
1336to an incorrect "lookbehind assertion is not fixed length" error.
1337
133823. The VERSION condition test was reading fractional PCRE2 version numbers
1339such as the 04 in 10.04 incorrectly and hence giving wrong results.
1340
134124. Updated to Unicode version 11.0.0. As well as the usual addition of new
1342scripts and characters, this involved re-jigging the grapheme break property
1343algorithm because Unicode has changed the way emojis are handled.
1344
134525. Fixed an obscure bug that struck when there were two atomic groups not
1346separated by something with a backtracking point. There could be an incorrect
1347backtrack into the first of the atomic groups. A complicated example is
1348/(?>a(*:1))(?>b)(*SKIP:1)x|.*/ matched against "abc", where the *SKIP
1349shouldn't find a MARK (because is in an atomic group), but it did.
1350
135126. Upgraded the perltest.sh script: (1) #pattern lines can now be used to set
1352a list of modifiers for all subsequent patterns - only those that the script
1353recognizes are meaningful; (2) #subject lines can be used to set or unset a
1354default "mark" modifier; (3) Unsupported #command lines give a warning when
1355they are ignored; (4) Mark data is output only if the "mark" modifier is
1356present.
1357
135827. (*ACCEPT:ARG), (*FAIL:ARG), and (*COMMIT:ARG) are now supported.
1359
136028. A (*MARK) name was not being passed back for positive assertions that were
1361terminated by (*ACCEPT).
1362
136329. Add support for \N{U+dddd}, but only in Unicode mode.
1364
136530. Add support for (?^) for unsetting all imnsx options.
1366
136731. The PCRE2_EXTENDED (/x) option only ever discarded space characters whose
1368code point was less than 256 and that were recognized by the lookup table
1369generated by pcre2_maketables(), which uses isspace() to identify white space.
1370Now, when Unicode support is compiled, PCRE2_EXTENDED also discards U+0085,
1371U+200E, U+200F, U+2028, and U+2029, which are additional characters defined by
1372Unicode as "Pattern White Space". This makes PCRE2 compatible with Perl.
1373
137432. In certain circumstances, option settings within patterns were not being
1375correctly processed. For example, the pattern /((?i)A)(?m)B/ incorrectly
1376matched "ab". (The (?m) setting lost the fact that (?i) should be reset at the
1377end of its group during the parse process, but without another setting such as
1378(?m) the compile phase got it right.) This bug was introduced by the
1379refactoring in release 10.23.
1380
138133. PCRE2 uses bcopy() if available when memmove() is not, and it used just to
1382define memmove() as function call to bcopy(). This hasn't been tested for a
1383long time because in pcre2test the result of memmove() was being used, whereas
1384bcopy() doesn't return a result. This feature is now refactored always to call
1385an emulation function when there is no memmove(). The emulation makes use of
1386bcopy() when available.
1387
138834. When serializing a pattern, set the memctl, executable_jit, and tables
1389fields (that is, all the fields that contain pointers) to zeros so that the
1390result of serializing is always the same. These fields are re-set when the
1391pattern is deserialized.
1392
139335. In a pattern such as /[^\x{100}-\x{ffff}]*[\x80-\xff]/ which has a repeated
1394negative class with no characters less than 0x100 followed by a positive class
1395with only characters less than 0x100, the first class was incorrectly being
1396auto-possessified, causing incorrect match failures.
1397
139836. Removed the character type bit ctype_meta, which dates from PCRE1 and is
1399not used in PCRE2.
1400
140137. Tidied up unnecessarily complicated macros used in the escapes table.
1402
140338. Since 10.21, the new testoutput8-16-4 file has accidentally been omitted
1404from distribution tarballs, owing to a typo in Makefile.am which had
1405testoutput8-16-3 twice. Now fixed.
1406
140739. If the only branch in a conditional subpattern was anchored, the whole
1408subpattern was treated as anchored, when it should not have been, since the
1409assumed empty second branch cannot be anchored. Demonstrated by test patterns
1410such as /(?(1)^())b/ or /(?(?=^))b/.
1411
141240. A repeated conditional subpattern that could match an empty string was
1413always assumed to be unanchored. Now it is checked just like any other
1414repeated conditional subpattern, and can be found to be anchored if the minimum
1415quantifier is one or more. I can't see much use for a repeated anchored
1416pattern, but the behaviour is now consistent.
1417
141841. Minor addition to pcre2_jit_compile.c to avoid static analyzer complaint
1419(for an event that could never occur but you had to have external information
1420to know that).
1421
142242. If before the first match in a file that was being searched by pcre2grep
1423there was a line that was sufficiently long to cause the input buffer to be
1424expanded, the variable holding the location of the end of the previous match
1425was being adjusted incorrectly, and could cause an overflow warning from a code
1426sanitizer. However, as the value is used only to print pending "after" lines
1427when the next match is reached (and there are no such lines in this case) this
1428bug could do no damage.
1429
1430
1431Version 10.31 12-February-2018
1432------------------------------
1433
14341. Fix typo (missing ]) in VMS code in pcre2test.c.
1435
14362. Replace the replicated code for matching extended Unicode grapheme sequences
1437(which got a lot more complicated by change 10.30/49) by a single subroutine
1438that is called by both pcre2_match() and pcre2_dfa_match().
1439
14403. Add idempotent guard to pcre2_internal.h.
1441
14424. Add new pcre2_config() options: PCRE2_CONFIG_NEVER_BACKSLASH_C and
1443PCRE2_CONFIG_COMPILED_WIDTHS.
1444
14455. Cut out \C tests in the JIT regression tests when NEVER_BACKSLASH_C is
1446defined (e.g. by --enable-never-backslash-C).
1447
14486. Defined public names for all the pcre2_compile() error numbers, and used
1449the public names in pcre2_convert.c.
1450
14517. Fixed a small memory leak in pcre2test (convert contexts).
1452
14538. Added two casts to compile.c and one to match.c to avoid compiler warnings.
1454
14559. Added code to pcre2grep when compiled under VMS to set the symbol
1456PCRE2GREP_RC to the exit status, because VMS does not distinguish between
1457exit(0) and exit(1).
1458
145910. Added the -LM (list modifiers) option to pcre2test. Also made -C complain
1460about a bad option only if the following argument item does not start with a
1461hyphen.
1462
146311. pcre2grep was truncating components of file names to 128 characters when
1464processing files with the -r option, and also (some very odd code) truncating
1465path names to 512 characters. There is now a check on the absolute length of
1466full path file names, which may be up to 2047 characters long.
1467
146812. When an assertion contained (*ACCEPT) it caused all open capturing groups
1469to be closed (as for a non-assertion ACCEPT), which was wrong and could lead to
1470misbehaviour for subsequent references to groups that started outside the
1471assertion. ACCEPT in an assertion now closes only those groups that were
1472started within that assertion. Fixes oss-fuzz issues 3852 and 3891.
1473
147413. Multiline matching in pcre2grep was misbehaving if the pattern matched
1475within a line, and then matched again at the end of the line and over into
1476subsequent lines. Behaviour was different with and without colouring, and
1477sometimes context lines were incorrectly printed and/or line endings were lost.
1478All these issues should now be fixed.
1479
148014. If --line-buffered was specified for pcre2grep when input was from a
1481compressed file (.gz or .bz2) a segfault occurred. (Line buffering should be
1482ignored for compressed files.)
1483
148415. Although pcre2_jit_match checks whether the pattern is compiled
1485in a given mode, it was also expected that at least one mode is available.
1486This is fixed and pcre2_jit_match returns with PCRE2_ERROR_JIT_BADOPTION
1487when the pattern is not optimized by JIT at all.
1488
148916. The line number and related variables such as match counts in pcre2grep
1490were all int variables, causing overflow when files with more than 2147483647
1491lines were processed (assuming 32-bit ints). They have all been changed to
1492unsigned long ints.
1493
149417. If a backreference with a minimum repeat count of zero was first in a
1495pattern, apart from assertions, an incorrect first matching character could be
1496recorded. For example, for the pattern /(?=(a))\1?b/, "b" was incorrectly set
1497as the first character of a match.
1498
149918. Characters in a leading positive assertion are considered for recording a
1500first character of a match when the rest of the pattern does not provide one.
1501However, a character in a non-assertive group within a leading assertion such
1502as in the pattern /(?=(a))\1?b/ caused this process to fail. This was an
1503infelicity rather than an outright bug, because it did not affect the result of
1504a match, just its speed. (In fact, in this case, the starting 'a' was
1505subsequently picked up in the study.)
1506
150719. A minor tidy in pcre2_match(): making all PCRE2_ERROR_ returns use "return"
1508instead of "RRETURN" saves unwinding the backtracks in these cases (only one
1509didn't).
1510
151120. Allocate a single callout block on the stack at the start of pcre2_match()
1512and set its never-changing fields once only. Do the same for pcre2_dfa_match().
1513
151421. Save the extra compile options (set in the compile context) with the
1515compiled pattern (they were not previously saved), add PCRE2_INFO_EXTRAOPTIONS
1516to retrieve them, and update pcre2test to show them.
1517
151822. Added PCRE2_CALLOUT_STARTMATCH and PCRE2_CALLOUT_BACKTRACK bits to a new
1519field callout_flags in callout blocks. The bits are set by pcre2_match(), but
1520not by JIT or pcre2_dfa_match(). Their settings are shown in pcre2test callouts
1521if the callout_extra subject modifier is set. These bits are provided to help
1522with tracking how a backtracking match is proceeding.
1523
152423. Updated the pcre2demo.c demonstration program, which was missing the extra
1525code for -g that handles the case when \K in an assertion causes the match to
1526end at the original start point. Also arranged for it to detect when \K causes
1527the end of a match to be before its start.
1528
152924. Similar to 23 above, strange things (including loops) could happen in
1530pcre2grep when \K was used in an assertion when --colour was used or in
1531multiline mode. The "end at original start point" bug is fixed, and if the end
1532point is found to be before the start point, they are swapped.
1533
153425. When PCRE2_FIRSTLINE without PCRE2_NO_START_OPTIMIZE was used in non-JIT
1535matching (both pcre2_match() and pcre2_dfa_match()) and the matched string
1536started with the first code unit of a newline sequence, matching failed because
1537it was not tried at the newline.
1538
153926. Code for giving up a non-partial match after failing to find a starting
1540code unit anywhere in the subject was missing when searching for one of a
1541number of code units (the bitmap case) in both pcre2_match() and
1542pcre2_dfa_match(). This was a missing optimization rather than a bug.
1543
154427. Tidied up the ACROSSCHAR macro to be like FORWARDCHAR and BACKCHAR, using a
1545pointer argument rather than a code unit value. This should not have affected
1546the generated code.
1547
154828. The JIT compiler has been updated.
1549
155029. Avoid pointer overflow for unset captures in pcre2_substring_list_get().
1551This could not actually cause a crash because it was always used in a memcpy()
1552call with zero length.
1553
155430. Some internal structures have a variable-length ovector[] as their last
1555element. Their actual memory is obtained dynamically, giving an ovector of
1556appropriate length. However, they are defined in the structure as
1557ovector[NUMBER], where NUMBER is large so that array bound checkers don't
1558grumble. The value of NUMBER was 10000, but a fuzzer exceeded 5000 capturing
1559groups, making the ovector larger than this. The number has been increased to
1560131072, which allows for the maximum number of captures (65535) plus the
1561overall match. This fixes oss-fuzz issue 5415.
1562
156331. Auto-possessification at the end of a capturing group was dependent on what
1564follows the group (e.g. /(a+)b/ would auto-possessify the a+) but this caused
1565incorrect behaviour when the group was called recursively from elsewhere in the
1566pattern where something different might follow. This bug is an unforseen
1567consequence of change #1 for 10.30 - the implementation of backtracking into
1568recursions. Iterators at the ends of capturing groups are no longer considered
1569for auto-possessification if the pattern contains any recursions. Fixes
1570Bugzilla #2232.
1571
1572
1573Version 10.30 14-August-2017
1574----------------------------
1575
15761. The main interpreter, pcre2_match(), has been refactored into a new version
1577that does not use recursive function calls (and therefore the stack) for
1578remembering backtracking positions. This makes --disable-stack-for-recursion a
1579NOOP. The new implementation allows backtracking into recursive group calls in
1580patterns, making it more compatible with Perl, and also fixes some other
1581hard-to-do issues such as #1887 in Bugzilla. The code is also cleaner because
1582the old code had a number of fudges to try to reduce stack usage. It seems to
1583run no slower than the old code.
1584
1585A number of bugs in the refactored code were subsequently fixed during testing
1586before release, but after the code was made available in the repository. These
1587bugs were never in fully released code, but are noted here for the record.
1588
1589  (a) If a pattern had fewer capturing parentheses than the ovector supplied in
1590      the match data block, a memory error (detectable by ASAN) occurred after
1591      a match, because the external block was being set from non-existent
1592      internal ovector fields. Fixes oss-fuzz issue 781.
1593
1594  (b) A pattern with very many capturing parentheses (when the internal frame
1595      size was greater than the initial frame vector on the stack) caused a
1596      crash. A vector on the heap is now set up at the start of matching if the
1597      vector on the stack is not big enough to handle at least 10 frames.
1598      Fixes oss-fuzz issue 783.
1599
1600  (c) Handling of (*VERB)s in recursions was wrong in some cases.
1601
1602  (d) Captures in negative assertions that were used as conditions were not
1603      happening if the assertion matched via (*ACCEPT).
1604
1605  (e) Mark values were not being passed out of recursions.
1606
1607  (f) Refactor some code in do_callout() to avoid picky compiler warnings about
1608      negative indices. Fixes oss-fuzz issue 1454.
1609
1610  (g) Similarly refactor the way the variable length ovector is addressed for
1611      similar reasons. Fixes oss-fuzz issue 1465.
1612
16132. Now that pcre2_match() no longer uses recursive function calls (see above),
1614the "match limit recursion" value seems misnamed. It still exists, and limits
1615the depth of tree that is searched. To avoid future confusion, it has been
1616renamed as "depth limit" in all relevant places (--with-depth-limit,
1617(*LIMIT_DEPTH), pcre2_set_depth_limit(), etc) but the old names are still
1618available for backwards compatibility.
1619
16203. Hardened pcre2test so as to reduce the number of bugs reported by fuzzers:
1621
1622  (a) Check for malloc failures when getting memory for the ovector (POSIX) or
1623      the match data block (non-POSIX).
1624
16254. In the 32-bit library in non-UTF mode, an attempt to find a Unicode property
1626for a character with a code point greater than 0x10ffff (the Unicode maximum)
1627caused a crash.
1628
16295. If a lookbehind assertion that contained a back reference to a group
1630appearing later in the pattern was compiled with the PCRE2_ANCHORED option,
1631undefined actions (often a segmentation fault) could occur, depending on what
1632other options were set. An example assertion is (?<!\1(abc)) where the
1633reference \1 precedes the group (abc). This fixes oss-fuzz issue 865.
1634
16356. Added the PCRE2_INFO_FRAMESIZE item to pcre2_pattern_info() and arranged for
1636pcre2test to use it to output the frame size when the "framesize" modifier is
1637given.
1638
16397. Reworked the recursive pattern matching in the JIT compiler to follow the
1640interpreter changes.
1641
16428. When the zero_terminate modifier was specified on a pcre2test subject line
1643for global matching, unpredictable things could happen. For example, in UTF-8
1644mode, the pattern //g,zero_terminate read random memory when matched against an
1645empty string with zero_terminate. This was a bug in pcre2test, not the library.
1646
16479. Moved some Windows-specific code in pcre2grep (introduced in 10.23/13) out
1648of the section that is compiled when Unix-style directory scanning is
1649available, and into a new section that is always compiled for Windows.
1650
165110. In pcre2test, explicitly close the file after an error during serialization
1652or deserialization (the "load" or "save" commands).
1653
165411. Fix memory leak in pcre2_serialize_decode() when the input is invalid.
1655
165612. Fix potential NULL dereference in pcre2_callout_enumerate() if called with
1657a NULL pattern pointer when Unicode support is available.
1658
165913. When the 32-bit library was being tested by pcre2test, error messages that
1660were longer than 64 code units could cause a buffer overflow. This was a bug in
1661pcre2test.
1662
166314. The alternative matching function, pcre2_dfa_match() misbehaved if it
1664encountered a character class with a possessive repeat, for example [a-f]{3}+.
1665
166615. The depth (formerly recursion) limit now applies to DFA matching (as
1667of 10.23/36); pcre2test has been upgraded so that \=find_limits works with DFA
1668matching to find the minimum value for this limit.
1669
167016. Since 10.21, if pcre2_match() was called with a null context, default
1671memory allocation functions were used instead of whatever was used when the
1672pattern was compiled.
1673
167417. Changes to the pcre2test "memory" modifier on a subject line. These apply
1675only to pcre2_match():
1676
1677  (a) Warn if null_context is set on both pattern and subject, because the
1678      memory details cannot then be shown.
1679
1680  (b) Remember (up to a certain number of) memory allocations and their
1681      lengths, and list only the lengths, so as to be system-independent.
1682      (In practice, the new interpreter never has more than 2 blocks allocated
1683      simultaneously.)
1684
168518. Make pcre2test detect an error return from pcre2_get_error_message(), give
1686a message, and abandon the run (this would have detected #13 above).
1687
168819. Implemented PCRE2_ENDANCHORED.
1689
169020. Applied Jason Hood's patches (slightly modified) to pcre2grep, to implement
1691the --output=text (-O) option and the inbuilt callout echo.
1692
169321. Extend auto-anchoring etc. to ignore groups with a zero qualifier and
1694single-branch conditions with a false condition (e.g. DEFINE) at the start of a
1695branch. For example, /(?(DEFINE)...)^A/ and /(...){0}^B/ are now flagged as
1696anchored.
1697
169822. Added an explicit limit on the amount of heap used by pcre2_match(), set by
1699pcre2_set_heap_limit() or (*LIMIT_HEAP=xxx). Upgraded pcre2test to show the
1700heap limit along with other pattern information, and to find the minimum when
1701the find_limits modifier is set.
1702
170323. Write to the last 8 bytes of the pcre2_real_code structure when a compiled
1704pattern is set up so as to initialize any padding the compiler might have
1705included. This avoids valgrind warnings when a compiled pattern is copied, in
1706particular when it is serialized.
1707
170824. Remove a redundant line of code left in accidentally a long time ago.
1709
171025. Remove a duplication typo in pcre2_tables.c
1711
171226. Correct an incorrect cast in pcre2_valid_utf.c
1713
171427. Update pcre2test, remove some unused code in pcre2_match(), and upgrade the
1715tests to improve coverage.
1716
171728. Some fixes/tidies as a result of looking at Coverity Scan output:
1718
1719    (a) Typo: ">" should be ">=" in opcode check in pcre2_auto_possess.c.
1720    (b) Added some casts to avoid "suspicious implicit sign extension".
1721    (c) Resource leaks in pcre2test in rare error cases.
1722    (d) Avoid warning for never-use case OP_TABLE_LENGTH which is just a fudge
1723        for checking at compile time that tables are the right size.
1724    (e) Add missing "fall through" comment.
1725
172629. Implemented PCRE2_EXTENDED_MORE and related /xx and (?xx) features.
1727
172830. Implement (?n: for PCRE2_NO_AUTO_CAPTURE, because Perl now has this.
1729
173031. If more than one of "push", "pushcopy", or "pushtablescopy" were set in
1731pcre2test, a crash could occur.
1732
173332. Make -bigstack in RunTest allocate a 64MiB stack (instead of 16MiB) so
1734that all the tests can run with clang's sanitizing options.
1735
173633. Implement extra compile options in the compile context and add the first
1737one: PCRE2_EXTRA_ALLOW_SURROGATE_ESCAPES.
1738
173934. Implement newline type PCRE2_NEWLINE_NUL.
1740
174135. A lookbehind assertion that had a zero-length branch caused undefined
1742behaviour when processed by pcre2_dfa_match(). This is oss-fuzz issue 1859.
1743
174436. The match limit value now also applies to pcre2_dfa_match() as there are
1745patterns that can use up a lot of resources without necessarily recursing very
1746deeply. (Compare item 10.23/36.) This should fix oss-fuzz #1761.
1747
174837. Implement PCRE2_EXTRA_BAD_ESCAPE_IS_LITERAL.
1749
175038. Fix returned offsets from regexec() when REG_STARTEND is used with a
1751starting offset greater than zero.
1752
175339. Implement REG_PEND (GNU extension) for the POSIX wrapper.
1754
175540. Implement the subject_literal modifier in pcre2test, and allow jitstack on
1756pattern lines.
1757
175841. Implement PCRE2_LITERAL and use it to support REG_NOSPEC.
1759
176042. Implement PCRE2_EXTRA_MATCH_LINE and PCRE2_EXTRA_MATCH_WORD for the benefit
1761of pcre2grep.
1762
176343. Re-implement pcre2grep's -F, -w, and -x options using PCRE2_LITERAL,
1764PCRE2_EXTRA_MATCH_WORD, and PCRE2_EXTRA_MATCH_LINE. This fixes two bugs:
1765
1766    (a) The -F option did not work for fixed strings containing \E.
1767    (b) The -w option did not work for patterns with multiple branches.
1768
176944. Added configuration options for the SELinux compatible execmem allocator in
1770JIT.
1771
177245. Increased the limit for searching for a "must be present" code unit in
1773subjects from 1000 to 2000 for 8-bit searches, since they use memchr() and are
1774much faster.
1775
177646. Arrange for anchored patterns to record and use "first code unit" data,
1777because this can give a fast "no match" without searching for a "required code
1778unit". Previously only non-anchored patterns did this.
1779
178047. Upgraded the Unicode tables from Unicode 8.0.0 to Unicode 10.0.0.
1781
178248. Add the callout_no_where modifier to pcre2test.
1783
178449. Update extended grapheme breaking rules to the latest set that are in
1785Unicode Standard Annex #29.
1786
178750. Added experimental foreign pattern conversion facilities
1788(pcre2_pattern_convert() and friends).
1789
179051. Change the macro FWRITE, used in pcre2grep, to FWRITE_IGNORE because FWRITE
1791is defined in a system header in cygwin. Also modified some of the #ifdefs in
1792pcre2grep related to Windows and Cygwin support.
1793
179452. Change 3(g) for 10.23 was a bit too zealous. If a hyphen that follows a
1795character class is the last character in the class, Perl does not give a
1796warning. PCRE2 now also treats this as a literal.
1797
179853. Related to 52, though PCRE2 was throwing an error for [[:digit:]-X] it was
1799not doing so for [\d-X] (and similar escapes), as is documented.
1800
180154. Fixed a MIPS issue in the JIT compiler reported by Joshua Kinard.
1802
180355. Fixed a "maybe uninitialized" warning for class_uchardata in \p handling in
1804pcre2_compile() which could never actually trigger (code should have been cut
1805out when Unicode support is disabled).
1806
1807
1808Version 10.23 14-February-2017
1809------------------------------
1810
18111. Extended pcre2test with the utf8_input modifier so that it is able to
1812generate all possible 16-bit and 32-bit code unit values in non-UTF modes.
1813
18142. In any wide-character mode (8-bit UTF or any 16-bit or 32-bit mode), without
1815PCRE2_UCP set, a negative character type such as \D in a positive class should
1816cause all characters greater than 255 to match, whatever else is in the class.
1817There was a bug that caused this not to happen if a Unicode property item was
1818added to such a class, for example [\D\P{Nd}] or [\W\pL].
1819
18203. There has been a major re-factoring of the pcre2_compile.c file. Most syntax
1821checking is now done in the pre-pass that identifies capturing groups. This has
1822reduced the amount of duplication and made the code tidier. While doing this,
1823some minor bugs and Perl incompatibilities were fixed, including:
1824
1825  (a) \Q\E in the middle of a quantifier such as A+\Q\E+ is now ignored instead
1826      of giving an invalid quantifier error.
1827
1828  (b) {0} can now be used after a group in a lookbehind assertion; previously
1829      this caused an "assertion is not fixed length" error.
1830
1831  (c) Perl always treats (?(DEFINE) as a "define" group, even if a group with
1832      the name "DEFINE" exists. PCRE2 now does likewise.
1833
1834  (d) A recursion condition test such as (?(R2)...) must now refer to an
1835      existing subpattern.
1836
1837  (e) A conditional recursion test such as (?(R)...) misbehaved if there was a
1838      group whose name began with "R".
1839
1840  (f) When testing zero-terminated patterns under valgrind, the terminating
1841      zero is now marked "no access". This catches bugs that would otherwise
1842      show up only with non-zero-terminated patterns.
1843
1844  (g) A hyphen appearing immediately after a POSIX character class (for example
1845      /[[:ascii:]-z]/) now generates an error. Perl does accept this as a
1846      literal, but gives a warning, so it seems best to fail it in PCRE.
1847
1848  (h) An empty \Q\E sequence may appear after a callout that precedes an
1849      assertion condition (it is, of course, ignored).
1850
1851One effect of the refactoring is that some error numbers and messages have
1852changed, and the pattern offset given for compiling errors is not always the
1853right-most character that has been read. In particular, for a variable-length
1854lookbehind assertion it now points to the start of the assertion. Another
1855change is that when a callout appears before a group, the "length of next
1856pattern item" that is passed now just gives the length of the opening
1857parenthesis item, not the length of the whole group. A length of zero is now
1858given only for a callout at the end of the pattern. Automatic callouts are no
1859longer inserted before and after explicit callouts in the pattern.
1860
1861A number of bugs in the refactored code were subsequently fixed during testing
1862before release, but after the code was made available in the repository. Many
1863of the bugs were discovered by fuzzing testing. Several of them were related to
1864the change from assuming a zero-terminated pattern (which previously had
1865required non-zero terminated strings to be copied). These bugs were never in
1866fully released code, but are noted here for the record.
1867
1868  (a) An overall recursion such as (?0) inside a lookbehind assertion was not
1869      being diagnosed as an error.
1870
1871  (b) In utf mode, the length of a *MARK (or other verb) name was being checked
1872      in characters instead of code units, which could lead to bad code being
1873      compiled, leading to unpredictable behaviour.
1874
1875  (c) In extended /x mode, characters whose code was greater than 255 caused
1876      a lookup outside one of the global tables. A similar bug existed for wide
1877      characters in *VERB names.
1878
1879  (d) The amount of memory needed for a compiled pattern was miscalculated if a
1880      lookbehind contained more than one toplevel branch and the first branch
1881      was of length zero.
1882
1883  (e) In UTF-8 or UTF-16 modes with PCRE2_EXTENDED (/x) set and a non-zero-
1884      terminated pattern, if a # comment ran on to the end of the pattern, one
1885      or more code units past the end were being read.
1886
1887  (f) An unterminated repeat at the end of a non-zero-terminated pattern (e.g.
1888      "{2,2") could cause reading beyond the pattern.
1889
1890  (g) When reading a callout string, if the end delimiter was at the end of the
1891      pattern one further code unit was read.
1892
1893  (h) An unterminated number after \g' could cause reading beyond the pattern.
1894
1895  (i) An insufficient memory size was being computed for compiling with
1896      PCRE2_AUTO_CALLOUT.
1897
1898  (j) A conditional group with an assertion condition used more memory than was
1899      allowed for it during parsing, so too many of them could therefore
1900      overrun a buffer.
1901
1902  (k) If parsing a pattern exactly filled the buffer, the internal test for
1903      overrun did not check when the final META_END item was added.
1904
1905  (l) If a lookbehind contained a subroutine call, and the called group
1906      contained an option setting such as (?s), and the PCRE2_ANCHORED option
1907      was set, unpredictable behaviour could occur. The underlying bug was
1908      incorrect code and insufficient checking while searching for the end of
1909      the called subroutine in the parsed pattern.
1910
1911  (m) Quantifiers following (*VERB)s were not being diagnosed as errors.
1912
1913  (n) The use of \Q...\E in a (*VERB) name when PCRE2_ALT_VERBNAMES and
1914      PCRE2_AUTO_CALLOUT were both specified caused undetermined behaviour.
1915
1916  (o) If \Q was preceded by a quantified item, and the following \E was
1917      followed by '?' or '+', and there was at least one literal character
1918      between them, an internal error "unexpected repeat" occurred (example:
1919      /.+\QX\E+/).
1920
1921  (p) A buffer overflow could occur while sorting the names in the group name
1922      list (depending on the order in which the names were seen).
1923
1924  (q) A conditional group that started with a callout was not doing the right
1925      check for a following assertion, leading to compiling bad code. Example:
1926      /(?(C'XX))?!XX/
1927
1928  (r) If a character whose code point was greater than 0xffff appeared within
1929      a lookbehind that was within another lookbehind, the calculation of the
1930      lookbehind length went wrong and could provoke an internal error.
1931
1932  (t) The sequence \E- or \Q\E- after a POSIX class in a character class caused
1933      an internal error. Now the hyphen is treated as a literal.
1934
19354. Back references are now permitted in lookbehind assertions when there are
1936no duplicated group numbers (that is, (?| has not been used), and, if the
1937reference is by name, there is only one group of that name. The referenced
1938group must, of course be of fixed length.
1939
19405. pcre2test has been upgraded so that, when run under valgrind with valgrind
1941support enabled, reading past the end of the pattern is detected, both when
1942compiling and during callout processing.
1943
19446. \g{+<number>} (e.g. \g{+2} ) is now supported. It is a "forward back
1945reference" and can be useful in repetitions (compare \g{-<number>} ). Perl does
1946not recognize this syntax.
1947
19487. Automatic callouts are no longer generated before and after callouts in the
1949pattern.
1950
19518. When pcre2test was outputting information from a callout, the caret indicator
1952for the current position in the subject line was incorrect if it was after an
1953escape sequence for a character whose code point was greater than \x{ff}.
1954
19559. Change 19 for 10.22 had a typo (PCRE_STATIC_RUNTIME should be
1956PCRE2_STATIC_RUNTIME). Fix from David Gaussmann.
1957
195810. Added --max-buffer-size to pcre2grep, to allow for automatic buffer
1959expansion when long lines are encountered. Original patch by Dmitry
1960Cherniachenko.
1961
196211. If pcre2grep was compiled with JIT support, but the library was compiled
1963without it (something that neither ./configure nor CMake allow, but it can be
1964done by editing config.h), pcre2grep was giving a JIT error. Now it detects
1965this situation and does not try to use JIT.
1966
196712. Added some "const" qualifiers to variables in pcre2grep.
1968
196913. Added Dmitry Cherniachenko's patch for colouring output in Windows
1970(untested by me). Also, look for GREP_COLOUR or GREP_COLOR if the environment
1971variables PCRE2GREP_COLOUR and PCRE2GREP_COLOR are not found.
1972
197314. Add the -t (grand total) option to pcre2grep.
1974
197515. A number of bugs have been mended relating to match start-up optimizations
1976when the first thing in a pattern is a positive lookahead. These all applied
1977only when PCRE2_NO_START_OPTIMIZE was *not* set:
1978
1979    (a) A pattern such as (?=.*X)X$ was incorrectly optimized as if it needed
1980        both an initial 'X' and a following 'X'.
1981    (b) Some patterns starting with an assertion that started with .* were
1982        incorrectly optimized as having to match at the start of the subject or
1983        after a newline. There are cases where this is not true, for example,
1984        (?=.*[A-Z])(?=.{8,16})(?!.*[\s]) matches after the start in lines that
1985        start with spaces. Starting .* in an assertion is no longer taken as an
1986        indication of matching at the start (or after a newline).
1987
198816. The "offset" modifier in pcre2test was not being ignored (as documented)
1989when the POSIX API was in use.
1990
199117. Added --enable-fuzz-support to "configure", causing an non-installed
1992library containing a test function that can be called by fuzzers to be
1993compiled. A non-installed  binary to run the test function locally, called
1994pcre2fuzzcheck is also compiled.
1995
199618. A pattern with PCRE2_DOTALL (/s) set but not PCRE2_NO_DOTSTAR_ANCHOR, and
1997which started with .* inside a positive lookahead was incorrectly being
1998compiled as implicitly anchored.
1999
200019. Removed all instances of "register" declarations, as they are considered
2001obsolete these days and in any case had become very haphazard.
2002
200320. Add strerror() to pcre2test for failed file opening.
2004
200521. Make pcre2test -C list valgrind support when it is enabled.
2006
200722. Add the use_length modifier to pcre2test.
2008
200923. Fix an off-by-one bug in pcre2test for the list of names for 'get' and
2010'copy' modifiers.
2011
201224. Add PCRE2_CALL_CONVENTION into the prototype declarations in pcre2.h as it
2013is apparently needed there as well as in the function definitions. (Why did
2014nobody ask for this in PCRE1?)
2015
201625. Change the _PCRE2_H and _PCRE2_UCP_H guard macros in the header files to
2017PCRE2_H_IDEMPOTENT_GUARD and PCRE2_UCP_H_IDEMPOTENT_GUARD to be more standard
2018compliant and unique.
2019
202026. pcre2-config --libs-posix was listing -lpcre2posix instead of
2021-lpcre2-posix. Also, the CMake build process was building the library with the
2022wrong name.
2023
202427. In pcre2test, give some offset information for errors in hex patterns.
2025This uses the C99 formatting sequence %td, except for MSVC which doesn't
2026support it - %lu is used instead.
2027
202828. Implemented pcre2_code_copy_with_tables(), and added pushtablescopy to
2029pcre2test for testing it.
2030
203129. Fix small memory leak in pcre2test.
2032
203330. Fix out-of-bounds read for partial matching of /./ against an empty string
2034when the newline type is CRLF.
2035
203631. Fix a bug in pcre2test that caused a crash when a locale was set either in
2037the current pattern or a previous one and a wide character was matched.
2038
203932. The appearance of \p, \P, or \X in a substitution string when
2040PCRE2_SUBSTITUTE_EXTENDED was set caused a segmentation fault (NULL
2041dereference).
2042
204333. If the starting offset was specified as greater than the subject length in
2044a call to pcre2_substitute() an out-of-bounds memory reference could occur.
2045
204634. When PCRE2 was compiled to use the heap instead of the stack for recursive
2047calls to match(), a repeated minimizing caseless back reference, or a
2048maximizing one where the two cases had different numbers of code units,
2049followed by a caseful back reference, could lose the caselessness of the first
2050repeated back reference (example: /(Z)(a)\2{1,2}?(?-i)\1X/i should match ZaAAZX
2051but didn't).
2052
205335. When a pattern is too complicated, PCRE2 gives up trying to find a minimum
2054matching length and just records zero. Typically this happens when there are
2055too many nested or recursive back references. If the limit was reached in
2056certain recursive cases it failed to be triggered and an internal error could
2057be the result.
2058
205936. The pcre2_dfa_match() function now takes note of the recursion limit for
2060the internal recursive calls that are used for lookrounds and recursions within
2061the pattern.
2062
206337. More refactoring has got rid of the internal could_be_empty_branch()
2064function (around 400 lines of code, including comments) by keeping track of
2065could-be-emptiness as the pattern is compiled instead of scanning compiled
2066groups. (This would have been much harder before the refactoring of #3 above.)
2067This lifts a restriction on the number of branches in a group (more than about
20681100 would give "pattern is too complicated").
2069
207038. Add the "-ac" command line option to pcre2test as a synonym for "-pattern
2071auto_callout".
2072
207339. In a library with Unicode support, incorrect data was compiled for a
2074pattern with PCRE2_UCP set without PCRE2_UTF if a class required all wide
2075characters to match (for example, /[\s[:^ascii:]]/).
2076
207740. The callout_error modifier has been added to pcre2test to make it possible
2078to return PCRE2_ERROR_CALLOUT from a callout.
2079
208041. A minor change to pcre2grep: colour reset is now "<esc>[0m" instead of
2081"<esc>[00m".
2082
208342. The limit in the auto-possessification code that was intended to catch
2084overly-complicated patterns and not spend too much time auto-possessifying was
2085being reset too often, resulting in very long compile times for some patterns.
2086Now such patterns are no longer completely auto-possessified.
2087
208843. Applied Jason Hood's revised patch for RunTest.bat.
2089
209044. Added a new Windows script RunGrepTest.bat, courtesy of Jason Hood.
2091
209245. Minor cosmetic fix to pcre2test: move a variable that is not used under
2093Windows into the "not Windows" code.
2094
209546. Applied Jason Hood's patches to upgrade pcre2grep under Windows and tidy
2096some of the code:
2097
2098  * normalised the Windows condition by ensuring WIN32 is defined;
2099  * enables the callout feature under Windows;
2100  * adds globbing (Microsoft's implementation expands quoted args),
2101    using a tweaked opendirectory;
2102  * implements the is_*_tty functions for Windows;
2103  * --color=always will write the ANSI sequences to file;
2104  * add sequences 4 (underline works on Win10) and 5 (blink as bright
2105    background, relatively standard on DOS/Win);
2106  * remove the (char *) casts for the now-const strings;
2107  * remove GREP_COLOUR (grep's command line allowed the 'u', but not
2108    the environment), parsing GREP_COLORS instead;
2109  * uses the current colour if not set, rather than black;
2110  * add print_match for the undefined case;
2111  * fixes a typo.
2112
2113In addition, colour settings containing anything other than digits and
2114semicolon are ignored, and the colour controls are no longer output for empty
2115strings.
2116
211747. Detecting patterns that are too large inside the length-measuring loop
2118saves processing ridiculously long patterns to their end.
2119
212048. Ignore PCRE2_CASELESS when processing \h, \H, \v, and \V in classes as it
2121just wastes time. In the UTF case it can also produce redundant entries in
2122XCLASS lists caused by characters with multiple other cases and pairs of
2123characters in the same "not-x" sublists.
2124
212549. A pattern such as /(?=(a\K))/ can report the end of the match being before
2126its start; pcre2test was not handling this correctly when using the POSIX
2127interface (it was OK with the native interface).
2128
212950. In pcre2grep, ignore all JIT compile errors. This means that pcre2grep will
2130continue to work, falling back to interpretation if anything goes wrong with
2131JIT.
2132
213351. Applied patches from Christian Persch to configure.ac to make use of the
2134AC_USE_SYSTEM_EXTENSIONS macro and to test for functions used by the JIT
2135modules.
2136
213752. Minor fixes to pcre2grep from Jason Hood:
2138    * fixed some spacing;
2139    * Windows doesn't usually use single quotes, so I've added a define
2140      to use appropriate quotes [in an example];
2141    * LC_ALL was displayed as "LCC_ALL";
2142    * numbers 11, 12 & 13 should end in "th";
2143    * use double quotes in usage message.
2144
214553. When autopossessifying, skip empty branches without recursion, to reduce
2146stack usage for the benefit of clang with -fsanitize-address, which uses huge
2147stack frames. Example pattern: /X?(R||){3335}/. Fixes oss-fuzz issue 553.
2148
214954. A pattern with very many explicit back references to a group that is a long
2150way from the start of the pattern could take a long time to compile because
2151searching for the referenced group in order to find the minimum length was
2152being done repeatedly. Now up to 128 group minimum lengths are cached and the
2153attempt to find a minimum length is abandoned if there is a back reference to a
2154group whose number is greater than 128. (In that case, the pattern is so
2155complicated that this optimization probably isn't worth it.) This fixes
2156oss-fuzz issue 557.
2157
215855. Issue 32 for 10.22 below was not correctly fixed. If pcre2grep in multiline
2159mode with --only-matching matched several lines, it restarted scanning at the
2160next line instead of moving on to the end of the matched string, which can be
2161several lines after the start.
2162
216356. Applied Jason Hood's new patch for RunGrepTest.bat that updates it in line
2164with updates to the non-Windows version.
2165
2166
2167
2168Version 10.22 29-July-2016
2169--------------------------
2170
21711. Applied Jason Hood's patches to RunTest.bat and testdata/wintestoutput3
2172to fix problems with running the tests under Windows.
2173
21742. Implemented a facility for quoting literal characters within hexadecimal
2175patterns in pcre2test, to make it easier to create patterns with just a few
2176non-printing characters.
2177
21783. Binary zeros are not supported in pcre2test input files. It now detects them
2179and gives an error.
2180
21814. Updated the valgrind parameters in RunTest: (a) changed smc-check=all to
2182smc-check=all-non-file; (b) changed obj:* in the suppression file to obj:??? so
2183that it matches only unknown objects.
2184
21855. Updated the maintenance script maint/ManyConfigTests to make it easier to
2186select individual groups of tests.
2187
21886. When the POSIX wrapper function regcomp() is called, the REG_NOSUB option
2189used to set PCRE2_NO_AUTO_CAPTURE when calling pcre2_compile(). However, this
2190disables the use of back references (and subroutine calls), which are supported
2191by other implementations of regcomp() with RE_NOSUB. Therefore, REG_NOSUB no
2192longer causes PCRE2_NO_AUTO_CAPTURE to be set, though it still ignores nmatch
2193and pmatch when regexec() is called.
2194
21957. Because of 6 above, pcre2test has been modified with a new modifier called
2196posix_nosub, to call regcomp() with REG_NOSUB. Previously the no_auto_capture
2197modifier had this effect. That option is now ignored when the POSIX API is in
2198use.
2199
22008. Minor tidies to the pcre2demo.c sample program, including more comments
2201about its 8-bit-ness.
2202
22039. Detect unmatched closing parentheses and give the error in the pre-scan
2204instead of later. Previously the pre-scan carried on and could give a
2205misleading incorrect error message. For example, /(?J)(?'a'))(?'a')/ gave a
2206message about invalid duplicate group names.
2207
220810. It has happened that pcre2test was accidentally linked with another POSIX
2209regex library instead of libpcre2-posix. In this situation, a call to regcomp()
2210(in the other library) may succeed, returning zero, but of course putting its
2211own data into the regex_t block. In one example the re_pcre2_code field was
2212left as NULL, which made pcre2test think it had not got a compiled POSIX regex,
2213so it treated the next line as another pattern line, resulting in a confusing
2214error message. A check has been added to pcre2test to see if the data returned
2215from a successful call of regcomp() are valid for PCRE2's regcomp(). If they
2216are not, an error message is output and the pcre2test run is abandoned. The
2217message points out the possibility of a mis-linking. Hopefully this will avoid
2218some head-scratching the next time this happens.
2219
222011. A pattern such as /(?<=((?C)0))/, which has a callout inside a lookbehind
2221assertion, caused pcre2test to output a very large number of spaces when the
2222callout was taken, making the program appearing to loop.
2223
222412. A pattern that included (*ACCEPT) in the middle of a sufficiently deeply
2225nested set of parentheses of sufficient size caused an overflow of the
2226compiling workspace (which was diagnosed, but of course is not desirable).
2227
222813. Detect missing closing parentheses during the pre-pass for group
2229identification.
2230
223114. Changed some integer variable types and put in a number of casts, following
2232a report of compiler warnings from Visual Studio 2013 and a few tests with
2233gcc's -Wconversion (which still throws up a lot).
2234
223515. Implemented pcre2_code_copy(), and added pushcopy and #popcopy to pcre2test
2236for testing it.
2237
223816. Change 66 for 10.21 introduced the use of snprintf() in PCRE2's version of
2239regerror(). When the error buffer is too small, my version of snprintf() puts a
2240binary zero in the final byte. Bug #1801 seems to show that other versions do
2241not do this, leading to bad output from pcre2test when it was checking for
2242buffer overflow. It no longer assumes a binary zero at the end of a too-small
2243regerror() buffer.
2244
224517. Fixed typo ("&&" for "&") in pcre2_study(). Fortunately, this could not
2246actually affect anything, by sheer luck.
2247
224818. Two minor fixes for MSVC compilation: (a) removal of apparently incorrect
2249"const" qualifiers in pcre2test and (b) defining snprintf as _snprintf for
2250older MSVC compilers. This has been done both in src/pcre2_internal.h for most
2251of the library, and also in src/pcre2posix.c, which no longer includes
2252pcre2_internal.h (see 24 below).
2253
225419. Applied Chris Wilson's patch (Bugzilla #1681) to CMakeLists.txt for MSVC
2255static compilation. Subsequently applied Chris Wilson's second patch, putting
2256the first patch under a new option instead of being unconditional when
2257PCRE_STATIC is set.
2258
225920. Updated pcre2grep to set stdout as binary when run under Windows, so as not
2260to convert \r\n at the ends of reflected lines into \r\r\n. This required
2261ensuring that other output that is written to stdout (e.g. file names) uses the
2262appropriate line terminator: \r\n for Windows, \n otherwise.
2263
226421. When a line is too long for pcre2grep's internal buffer, show the maximum
2265length in the error message.
2266
226722. Added support for string callouts to pcre2grep (Zoltan's patch with PH
2268additions).
2269
227023. RunTest.bat was missing a "set type" line for test 22.
2271
227224. The pcre2posix.c file was including pcre2_internal.h, and using some
2273"private" knowledge of the data structures. This is unnecessary; the code has
2274been re-factored and no longer includes pcre2_internal.h.
2275
227625. A racing condition is fixed in JIT reported by Mozilla.
2277
227826. Minor code refactor to avoid "array subscript is below array bounds"
2279compiler warning.
2280
228127. Minor code refactor to avoid "left shift of negative number" warning.
2282
228328. Add a bit more sanity checking to pcre2_serialize_decode() and document
2284that it expects trusted data.
2285
228629. Fix typo in pcre2_jit_test.c
2287
228830. Due to an oversight, pcre2grep was not making use of JIT when available.
2289This is now fixed.
2290
229131. The RunGrepTest script is updated to use the valgrind suppressions file
2292when testing with JIT under valgrind (compare 10.21/51 below). The suppressions
2293file is updated so that is now the same as for PCRE1: it suppresses the
2294Memcheck warnings Addr16 and Cond in unknown objects (that is, JIT-compiled
2295code). Also changed smc-check=all to smc-check=all-non-file as was done for
2296RunTest (see 4 above).
2297
229832. Implemented the PCRE2_NO_JIT option for pcre2_match().
2299
230033. Fix typo that gave a compiler error when JIT not supported.
2301
230234. Fix comment describing the returns from find_fixedlength().
2303
230435. Fix potential negative index in pcre2test.
2305
230636. Calls to pcre2_get_error_message() with error numbers that are never
2307returned by PCRE2 functions were returning empty strings. Now the error code
2308PCRE2_ERROR_BADDATA is returned. A facility has been added to pcre2test to
2309show the texts for given error numbers (i.e. to call pcre2_get_error_message()
2310and display what it returns) and a few representative error codes are now
2311checked in RunTest.
2312
231337. Added "&& !defined(__INTEL_COMPILER)" to the test for __GNUC__ in
2314pcre2_match.c, in anticipation that this is needed for the same reason it was
2315recently added to pcrecpp.cc in PCRE1.
2316
231738. Using -o with -M in pcre2grep could cause unnecessary repeated output when
2318the match extended over a line boundary, as it tried to find more matches "on
2319the same line" - but it was already over the end.
2320
232139. Allow \C in lookbehinds and DFA matching in UTF-32 mode (by converting it
2322to the same code as '.' when PCRE2_DOTALL is set).
2323
232440. Fix two clang compiler warnings in pcre2test when only one code unit width
2325is supported.
2326
232741. Upgrade RunTest to automatically re-run test 2 with a large (64MiB) stack
2328if it fails when running the interpreter with a 16MiB stack (and if changing
2329the stack size via pcre2test is possible). This avoids having to manually set a
2330large stack size when testing with clang.
2331
233242. Fix register overwrite in JIT when SSE2 acceleration is enabled.
2333
233443. Detect integer overflow in pcre2test pattern and data repetition counts.
2335
233644. In pcre2test, ignore "allcaptures" after DFA matching.
2337
233845. Fix unaligned accesses on x86. Patch by Marc Mutz.
2339
234046. Fix some more clang compiler warnings.
2341
2342
2343Version 10.21 12-January-2016
2344-----------------------------
2345
23461. Improve matching speed of patterns starting with + or * in JIT.
2347
23482. Use memchr() to find the first character in an unanchored match in 8-bit
2349mode in the interpreter. This gives a significant speed improvement.
2350
23513. Removed a redundant copy of the opcode_possessify table in the
2352pcre2_auto_possessify.c source.
2353
23544. Fix typos in dftables.c for z/OS.
2355
23565. Change 36 for 10.20 broke the handling of [[:>:]] and [[:<:]] in that
2357processing them could involve a buffer overflow if the following character was
2358an opening parenthesis.
2359
23606. Change 36 for 10.20 also introduced a bug in processing this pattern:
2361/((?x)(*:0))#(?'/. Specifically: if a setting of (?x) was followed by a (*MARK)
2362setting (which (*:0) is), then (?x) did not get unset at the end of its group
2363during the scan for named groups, and hence the external # was incorrectly
2364treated as a comment and the invalid (?' at the end of the pattern was not
2365diagnosed. This caused a buffer overflow during the real compile. This bug was
2366discovered by Karl Skomski with the LLVM fuzzer.
2367
23687. Moved the pcre2_find_bracket() function from src/pcre2_compile.c into its
2369own source module to avoid a circular dependency between src/pcre2_compile.c
2370and src/pcre2_study.c
2371
23728. A callout with a string argument containing an opening square bracket, for
2373example /(?C$[$)(?<]/, was incorrectly processed and could provoke a buffer
2374overflow. This bug was discovered by Karl Skomski with the LLVM fuzzer.
2375
23769. The handling of callouts during the pre-pass for named group identification
2377has been tightened up.
2378
237910. The quantifier {1} can be ignored, whether greedy, non-greedy, or
2380possessive. This is a very minor optimization.
2381
238211. A possessively repeated conditional group that could match an empty string,
2383for example, /(?(R))*+/, was incorrectly compiled.
2384
238512. The Unicode tables have been updated to Unicode 8.0.0 (thanks to Christian
2386Persch).
2387
238813. An empty comment (?#) in a pattern was incorrectly processed and could
2389provoke a buffer overflow. This bug was discovered by Karl Skomski with the
2390LLVM fuzzer.
2391
239214. Fix infinite recursion in the JIT compiler when certain patterns such as
2393/(?:|a|){100}x/ are analysed.
2394
239515. Some patterns with character classes involving [: and \\ were incorrectly
2396compiled and could cause reading from uninitialized memory or an incorrect
2397error diagnosis. Examples are: /[[:\\](?<[::]/ and /[[:\\](?'abc')[a:]. The
2398first of these bugs was discovered by Karl Skomski with the LLVM fuzzer.
2399
240016. Pathological patterns containing many nested occurrences of [: caused
2401pcre2_compile() to run for a very long time. This bug was found by the LLVM
2402fuzzer.
2403
240417. A missing closing parenthesis for a callout with a string argument was not
2405being diagnosed, possibly leading to a buffer overflow. This bug was found by
2406the LLVM fuzzer.
2407
240818. A conditional group with only one branch has an implicit empty alternative
2409branch and must therefore be treated as potentially matching an empty string.
2410
241119. If (?R was followed by - or + incorrect behaviour happened instead of a
2412diagnostic. This bug was discovered by Karl Skomski with the LLVM fuzzer.
2413
241420. Another bug that was introduced by change 36 for 10.20: conditional groups
2415whose condition was an assertion preceded by an explicit callout with a string
2416argument might be incorrectly processed, especially if the string contained \Q.
2417This bug was discovered by Karl Skomski with the LLVM fuzzer.
2418
241921. Compiling PCRE2 with the sanitize options of clang showed up a number of
2420very pedantic coding infelicities and a buffer overflow while checking a UTF-8
2421string if the final multi-byte UTF-8 character was truncated.
2422
242322. For Perl compatibility in EBCDIC environments, ranges such as a-z in a
2424class, where both values are literal letters in the same case, omit the
2425non-letter EBCDIC code points within the range.
2426
242723. Finding the minimum matching length of complex patterns with back
2428references and/or recursions can take a long time. There is now a cut-off that
2429gives up trying to find a minimum length when things get too complex.
2430
243124. An optimization has been added that speeds up finding the minimum matching
2432length for patterns containing repeated capturing groups or recursions.
2433
243425. If a pattern contained a back reference to a group whose number was
2435duplicated as a result of appearing in a (?|...) group, the computation of the
2436minimum matching length gave a wrong result, which could cause incorrect "no
2437match" errors. For such patterns, a minimum matching length cannot at present
2438be computed.
2439
244026. Added a check for integer overflow in conditions (?(<digits>) and
2441(?(R<digits>). This omission was discovered by Karl Skomski with the LLVM
2442fuzzer.
2443
244427. Fixed an issue when \p{Any} inside an xclass did not read the current
2445character.
2446
244728. If pcre2grep was given the -q option with -c or -l, or when handling a
2448binary file, it incorrectly wrote output to stdout.
2449
245029. The JIT compiler did not restore the control verb head in case of *THEN
2451control verbs. This issue was found by Karl Skomski with a custom LLVM fuzzer.
2452
245330. The way recursive references such as (?3) are compiled has been re-written
2454because the old way was the cause of many issues. Now, conversion of the group
2455number into a pattern offset does not happen until the pattern has been
2456completely compiled. This does mean that detection of all infinitely looping
2457recursions is postponed till match time. In the past, some easy ones were
2458detected at compile time. This re-writing was done in response to yet another
2459bug found by the LLVM fuzzer.
2460
246131. A test for a back reference to a non-existent group was missing for items
2462such as \987. This caused incorrect code to be compiled. This issue was found
2463by Karl Skomski with a custom LLVM fuzzer.
2464
246532. Error messages for syntax errors following \g and \k were giving inaccurate
2466offsets in the pattern.
2467
246833. Improve the performance of starting single character repetitions in JIT.
2469
247034. (*LIMIT_MATCH=) now gives an error instead of setting the value to 0.
2471
247235. Error messages for syntax errors in *LIMIT_MATCH and *LIMIT_RECURSION now
2473give the right offset instead of zero.
2474
247536. The JIT compiler should not check repeats after a {0,1} repeat byte code.
2476This issue was found by Karl Skomski with a custom LLVM fuzzer.
2477
247837. The JIT compiler should restore the control chain for empty possessive
2479repeats. This issue was found by Karl Skomski with a custom LLVM fuzzer.
2480
248138. A bug which was introduced by the single character repetition optimization
2482was fixed.
2483
248439. Match limit check added to recursion. This issue was found by Karl Skomski
2485with a custom LLVM fuzzer.
2486
248740. Arrange for the UTF check in pcre2_match() and pcre2_dfa_match() to look
2488only at the part of the subject that is relevant when the starting offset is
2489non-zero.
2490
249141. Improve first character match in JIT with SSE2 on x86.
2492
249342. Fix two assertion fails in JIT. These issues were found by Karl Skomski
2494with a custom LLVM fuzzer.
2495
249643. Correct the setting of CMAKE_C_FLAGS in CMakeLists.txt (patch from Roy Ivy
2497III).
2498
249944. Fix bug in RunTest.bat for new test 14, and adjust the script for the added
2500test (there are now 20 in total).
2501
250245. Fixed a corner case of range optimization in JIT.
2503
250446. Add the ${*MARK} facility to pcre2_substitute().
2505
250647. Modifier lists in pcre2test were splitting at spaces without the required
2507commas.
2508
250948. Implemented PCRE2_ALT_VERBNAMES.
2510
251149. Fixed two issues in JIT. These were found by Karl Skomski with a custom
2512LLVM fuzzer.
2513
251450. The pcre2test program has been extended by adding the #newline_default
2515command. This has made it possible to run the standard tests when PCRE2 is
2516compiled with either CR or CRLF as the default newline convention. As part of
2517this work, the new command was added to several test files and the testing
2518scripts were modified. The pcre2grep tests can now also be run when there is no
2519LF in the default newline convention.
2520
252151. The RunTest script has been modified so that, when JIT is used and valgrind
2522is specified, a valgrind suppressions file is set up to ignore "Invalid read of
2523size 16" errors because these are false positives when the hardware supports
2524the SSE2 instruction set.
2525
252652. It is now possible to have comment lines amid the subject strings in
2527pcre2test (and perltest.sh) input.
2528
252953. Implemented PCRE2_USE_OFFSET_LIMIT and pcre2_set_offset_limit().
2530
253154. Add the null_context modifier to pcre2test so that calling pcre2_compile()
2532and the matching functions with NULL contexts can be tested.
2533
253455. Implemented PCRE2_SUBSTITUTE_EXTENDED.
2535
253656. In a character class such as [\W\p{Any}] where both a negative-type escape
2537("not a word character") and a property escape were present, the property
2538escape was being ignored.
2539
254057. Fixed integer overflow for patterns whose minimum matching length is very,
2541very large.
2542
254358. Implemented --never-backslash-C.
2544
254559. Change 55 above introduced a bug by which certain patterns provoked the
2546erroneous error "\ at end of pattern".
2547
254860. The special sequences [[:<:]] and [[:>:]] gave rise to incorrect compiling
2549errors or other strange effects if compiled in UCP mode. Found with libFuzzer
2550and AddressSanitizer.
2551
255261. Whitespace at the end of a pcre2test pattern line caused a spurious error
2553message if there were only single-character modifiers. It should be ignored.
2554
255562. The use of PCRE2_NO_AUTO_CAPTURE could cause incorrect compilation results
2556or segmentation errors for some patterns. Found with libFuzzer and
2557AddressSanitizer.
2558
255963. Very long names in (*MARK) or (*THEN) etc. items could provoke a buffer
2560overflow.
2561
256264. Improve error message for overly-complicated patterns.
2563
256465. Implemented an optional replication feature for patterns in pcre2test, to
2565make it easier to test long repetitive patterns. The tests for 63 above are
2566converted to use the new feature.
2567
256866. In the POSIX wrapper, if regerror() was given too small a buffer, it could
2569misbehave.
2570
257167. In pcre2_substitute() in UTF mode, the UTF validity check on the
2572replacement string was happening before the length setting when the replacement
2573string was zero-terminated.
2574
257568. In pcre2_substitute() in UTF mode, PCRE2_NO_UTF_CHECK can be set for the
2576second and subsequent calls to pcre2_match().
2577
257869. There was no check for integer overflow for a replacement group number in
2579pcre2_substitute(). An added check for a number greater than the largest group
2580number in the pattern means this is not now needed.
2581
258270. The PCRE2-specific VERSION condition didn't work correctly if only one
2583digit was given after the decimal point, or if more than two digits were given.
2584It now works with one or two digits, and gives a compile time error if more are
2585given.
2586
258771. In pcre2_substitute() there was the possibility of reading one code unit
2588beyond the end of the replacement string.
2589
259072. The code for checking a subject's UTF-32 validity for a pattern with a
2591lookbehind involved an out-of-bounds pointer, which could potentially cause
2592trouble in some environments.
2593
259473. The maximum lookbehind length was incorrectly calculated for patterns such
2595as /(?<=(a)(?-1))x/ which have a recursion within a backreference.
2596
259774. Give an error if a lookbehind assertion is longer than 65535 code units.
2598
259975. Give an error in pcre2_substitute() if a match ends before it starts (as a
2600result of the use of \K).
2601
260276. Check the length of subpattern names and the names in (*MARK:xx) etc.
2603dynamically to avoid the possibility of integer overflow.
2604
260577. Implement pcre2_set_max_pattern_length() so that programs can restrict the
2606size of patterns that they are prepared to handle.
2607
260878. (*NO_AUTO_POSSESS) was not working.
2609
261079. Adding group information caching improves the speed of compiling when
2611checking whether a group has a fixed length and/or could match an empty string,
2612especially when recursion or subroutine calls are involved. However, this
2613cannot be used when (?| is present in the pattern because the same number may
2614be used for groups of different sizes. To catch runaway patterns in this
2615situation, counts have been introduced to the functions that scan for empty
2616branches or compute fixed lengths.
2617
261880. Allow for the possibility of the size of the nest_save structure not being
2619a factor of the size of the compiling workspace (it currently is).
2620
262181. Check for integer overflow in minimum length calculation and cap it at
262265535.
2623
262482. Small optimizations in code for finding the minimum matching length.
2625
262683. Lock out configuring for EBCDIC with non-8-bit libraries.
2627
262884. Test for error code <= 0 in regerror().
2629
263085. Check for too many replacements (more than INT_MAX) in pcre2_substitute().
2631
263286. Avoid the possibility of computing with an out-of-bounds pointer (though
2633not dereferencing it) while handling lookbehind assertions.
2634
263587. Failure to get memory for the match data in regcomp() is now given as a
2636regcomp() error instead of waiting for regexec() to pick it up.
2637
263888. In pcre2_substitute(), ensure that CRLF is not split when it is a valid
2639newline sequence.
2640
264189. Paranoid check in regcomp() for bad error code from pcre2_compile().
2642
264390. Run test 8 (internal offsets and code sizes) for link sizes 3 and 4 as well
2644as for link size 2.
2645
264691. Document that JIT has a limit on pattern size, and give more information
2647about JIT compile failures in pcre2test.
2648
264992. Implement PCRE2_INFO_HASBACKSLASHC.
2650
265193. Re-arrange valgrind support code in pcre2test to avoid spurious reports
2652with JIT (possibly caused by SSE2?).
2653
265494. Support offset_limit in JIT.
2655
265695. A sequence such as [[:punct:]b] that is, a POSIX character class followed
2657by a single ASCII character in a class item, was incorrectly compiled in UCP
2658mode. The POSIX class got lost, but only if the single character followed it.
2659
266096. [:punct:] in UCP mode was matching some characters in the range 128-255
2661that should not have been matched.
2662
266397. If [:^ascii:] or [:^xdigit:] are present in a non-negated class, all
2664characters with code points greater than 255 are in the class. When a Unicode
2665property was also in the class (if PCRE2_UCP is set, escapes such as \w are
2666turned into Unicode properties), wide characters were not correctly handled,
2667and could fail to match.
2668
266998. In pcre2test, make the "startoffset" modifier a synonym of "offset",
2670because it sets the "startoffset" parameter for pcre2_match().
2671
267299. If PCRE2_AUTO_CALLOUT was set on a pattern that had a (?# comment between
2673an item and its qualifier (for example, A(?#comment)?B) pcre2_compile()
2674misbehaved. This bug was found by the LLVM fuzzer.
2675
2676100. The error for an invalid UTF pattern string always gave the code unit
2677offset as zero instead of where the invalidity was found.
2678
2679101. Further to 97 above, negated classes such as [^[:^ascii:]\d] were also not
2680working correctly in UCP mode.
2681
2682102. Similar to 99 above, if an isolated \E was present between an item and its
2683qualifier when PCRE2_AUTO_CALLOUT was set, pcre2_compile() misbehaved. This bug
2684was found by the LLVM fuzzer.
2685
2686103. The POSIX wrapper function regexec() crashed if the option REG_STARTEND
2687was set when the pmatch argument was NULL. It now returns REG_INVARG.
2688
2689104. Allow for up to 32-bit numbers in the ordin() function in pcre2grep.
2690
2691105. An empty \Q\E sequence between an item and its qualifier caused
2692pcre2_compile() to misbehave when auto callouts were enabled. This bug
2693was found by the LLVM fuzzer.
2694
2695106. If both PCRE2_ALT_VERBNAMES and PCRE2_EXTENDED were set, and a (*MARK) or
2696other verb "name" ended with whitespace immediately before the closing
2697parenthesis, pcre2_compile() misbehaved. Example: /(*:abc )/, but only when
2698both those options were set.
2699
2700107. In a number of places pcre2_compile() was not handling NULL characters
2701correctly, and pcre2test with the "bincode" modifier was not always correctly
2702displaying fields containing NULLS:
2703
2704   (a) Within /x extended #-comments
2705   (b) Within the "name" part of (*MARK) and other *verbs
2706   (c) Within the text argument of a callout
2707
2708108. If a pattern that was compiled with PCRE2_EXTENDED started with white
2709space or a #-type comment that was followed by (?-x), which turns off
2710PCRE2_EXTENDED, and there was no subsequent (?x) to turn it on again,
2711pcre2_compile() assumed that (?-x) applied to the whole pattern and
2712consequently mis-compiled it. This bug was found by the LLVM fuzzer. The fix
2713for this bug means that a setting of any of the (?imsxJU) options at the start
2714of a pattern is no longer transferred to the options that are returned by
2715PCRE2_INFO_ALLOPTIONS. In fact, this was an anachronism that should have
2716changed when the effects of those options were all moved to compile time.
2717
2718109. An escaped closing parenthesis in the "name" part of a (*verb) when
2719PCRE2_ALT_VERBNAMES was set caused pcre2_compile() to malfunction. This bug
2720was found by the LLVM fuzzer.
2721
2722110. Implemented PCRE2_SUBSTITUTE_UNSET_EMPTY, and updated pcre2test to make it
2723possible to test it.
2724
2725111. "Harden" pcre2test against ridiculously large values in modifiers and
2726command line arguments.
2727
2728112. Implemented PCRE2_SUBSTITUTE_UNKNOWN_UNSET and PCRE2_SUBSTITUTE_OVERFLOW_
2729LENGTH.
2730
2731113. Fix printing of *MARK names that contain binary zeroes in pcre2test.
2732
2733
2734Version 10.20 30-June-2015
2735--------------------------
2736
27371. Callouts with string arguments have been added.
2738
27392. Assertion code generator in JIT has been optimized.
2740
27413. The invalid pattern (?(?C) has a missing assertion condition at the end. The
2742pcre2_compile() function read past the end of the input before diagnosing an
2743error. This bug was discovered by the LLVM fuzzer.
2744
27454. Implemented pcre2_callout_enumerate().
2746
27475. Fix JIT compilation of conditional blocks whose assertion is converted to
2748(*FAIL). E.g: /(?(?!))/.
2749
27506. The pattern /(?(?!)^)/ caused references to random memory. This bug was
2751discovered by the LLVM fuzzer.
2752
27537. The assertion (?!) is optimized to (*FAIL). This was not handled correctly
2754when this assertion was used as a condition, for example (?(?!)a|b). In
2755pcre2_match() it worked by luck; in pcre2_dfa_match() it gave an incorrect
2756error about an unsupported item.
2757
27588. For some types of pattern, for example /Z*(|d*){216}/, the auto-
2759possessification code could take exponential time to complete. A recursion
2760depth limit of 1000 has been imposed to limit the resources used by this
2761optimization. This infelicity was discovered by the LLVM fuzzer.
2762
27639. A pattern such as /(*UTF)[\S\V\H]/, which contains a negated special class
2764such as \S in non-UCP mode, explicit wide characters (> 255) can be ignored
2765because \S ensures they are all in the class. The code for doing this was
2766interacting badly with the code for computing the amount of space needed to
2767compile the pattern, leading to a buffer overflow. This bug was discovered by
2768the LLVM fuzzer.
2769
277010. A pattern such as /((?2)+)((?1))/ which has mutual recursion nested inside
2771other kinds of group caused stack overflow at compile time. This bug was
2772discovered by the LLVM fuzzer.
2773
277411. A pattern such as /(?1)(?#?'){8}(a)/ which had a parenthesized comment
2775between a subroutine call and its quantifier was incorrectly compiled, leading
2776to buffer overflow or other errors. This bug was discovered by the LLVM fuzzer.
2777
277812. The illegal pattern /(?(?<E>.*!.*)?)/ was not being diagnosed as missing an
2779assertion after (?(. The code was failing to check the character after (?(?<
2780for the ! or = that would indicate a lookbehind assertion. This bug was
2781discovered by the LLVM fuzzer.
2782
278313. A pattern such as /X((?2)()*+){2}+/ which has a possessive quantifier with
2784a fixed maximum following a group that contains a subroutine reference was
2785incorrectly compiled and could trigger buffer overflow. This bug was discovered
2786by the LLVM fuzzer.
2787
278814. Negative relative recursive references such as (?-7) to non-existent
2789subpatterns were not being diagnosed and could lead to unpredictable behaviour.
2790This bug was discovered by the LLVM fuzzer.
2791
279215. The bug fixed in 14 was due to an integer variable that was unsigned when
2793it should have been signed. Some other "int" variables, having been checked,
2794have either been changed to uint32_t or commented as "must be signed".
2795
279616. A mutual recursion within a lookbehind assertion such as (?<=((?2))((?1)))
2797caused a stack overflow instead of the diagnosis of a non-fixed length
2798lookbehind assertion. This bug was discovered by the LLVM fuzzer.
2799
280017. The use of \K in a positive lookbehind assertion in a non-anchored pattern
2801(e.g. /(?<=\Ka)/) could make pcre2grep loop.
2802
280318. There was a similar problem to 17 in pcre2test for global matches, though
2804the code there did catch the loop.
2805
280619. If a greedy quantified \X was preceded by \C in UTF mode (e.g. \C\X*),
2807and a subsequent item in the pattern caused a non-match, backtracking over the
2808repeated \X did not stop, but carried on past the start of the subject, causing
2809reference to random memory and/or a segfault. There were also some other cases
2810where backtracking after \C could crash. This set of bugs was discovered by the
2811LLVM fuzzer.
2812
281320. The function for finding the minimum length of a matching string could take
2814a very long time if mutual recursion was present many times in a pattern, for
2815example, /((?2){73}(?2))((?1))/. A better mutual recursion detection method has
2816been implemented. This infelicity was discovered by the LLVM fuzzer.
2817
281821. Implemented PCRE2_NEVER_BACKSLASH_C.
2819
282022. The feature for string replication in pcre2test could read from freed
2821memory if the replication required a buffer to be extended, and it was not
2822working properly in 16-bit and 32-bit modes. This issue was discovered by a
2823fuzzer: see http://lcamtuf.coredump.cx/afl/.
2824
282523. Added the PCRE2_ALT_CIRCUMFLEX option.
2826
282724. Adjust the treatment of \8 and \9 to be the same as the current Perl
2828behaviour.
2829
283025. Static linking against the PCRE2 library using the pkg-config module was
2831failing on missing pthread symbols.
2832
283326. If a group that contained a recursive back reference also contained a
2834forward reference subroutine call followed by a non-forward-reference
2835subroutine call, for example /.((?2)(?R)\1)()/, pcre2_compile() failed to
2836compile correct code, leading to undefined behaviour or an internally detected
2837error. This bug was discovered by the LLVM fuzzer.
2838
283927. Quantification of certain items (e.g. atomic back references) could cause
2840incorrect code to be compiled when recursive forward references were involved.
2841For example, in this pattern: /(?1)()((((((\1++))\x85)+)|))/. This bug was
2842discovered by the LLVM fuzzer.
2843
284428. A repeated conditional group whose condition was a reference by name caused
2845a buffer overflow if there was more than one group with the given name. This
2846bug was discovered by the LLVM fuzzer.
2847
284829. A recursive back reference by name within a group that had the same name as
2849another group caused a buffer overflow. For example: /(?J)(?'d'(?'d'\g{d}))/.
2850This bug was discovered by the LLVM fuzzer.
2851
285230. A forward reference by name to a group whose number is the same as the
2853current group, for example in this pattern: /(?|(\k'Pm')|(?'Pm'))/, caused a
2854buffer overflow at compile time. This bug was discovered by the LLVM fuzzer.
2855
285631. Fix -fsanitize=undefined warnings for left shifts of 1 by 31 (it treats 1
2857as an int; fixed by writing it as 1u).
2858
285932. Fix pcre2grep compile when -std=c99 is used with gcc, though it still gives
2860a warning for "fileno" unless -std=gnu99 us used.
2861
286233. A lookbehind assertion within a set of mutually recursive subpatterns could
2863provoke a buffer overflow. This bug was discovered by the LLVM fuzzer.
2864
286534. Give an error for an empty subpattern name such as (?'').
2866
286735. Make pcre2test give an error if a pattern that follows #forbud_utf contains
2868\P, \p, or \X.
2869
287036. The way named subpatterns are handled has been refactored. There is now a
2871pre-pass over the regex which does nothing other than identify named
2872subpatterns and count the total captures. This means that information about
2873named patterns is known before the rest of the compile. In particular, it means
2874that forward references can be checked as they are encountered. Previously, the
2875code for handling forward references was contorted and led to several errors in
2876computing the memory requirements for some patterns, leading to buffer
2877overflows.
2878
287937. There was no check for integer overflow in subroutine calls such as (?123).
2880
288138. The table entry for \l in EBCDIC environments was incorrect, leading to its
2882being treated as a literal 'l' instead of causing an error.
2883
288439. If a non-capturing group containing a conditional group that could match
2885an empty string was repeated, it was not identified as matching an empty string
2886itself. For example: /^(?:(?(1)x|)+)+$()/.
2887
288840. In an EBCDIC environment, pcretest was mishandling the escape sequences
2889\a and \e in test subject lines.
2890
289141. In an EBCDIC environment, \a in a pattern was converted to the ASCII
2892instead of the EBCDIC value.
2893
289442. The handling of \c in an EBCDIC environment has been revised so that it is
2895now compatible with the specification in Perl's perlebcdic page.
2896
289743. Single character repetition in JIT has been improved. 20-30% speedup
2898was achieved on certain patterns.
2899
290044. The EBCDIC character 0x41 is a non-breaking space, equivalent to 0xa0 in
2901ASCII/Unicode. This has now been added to the list of characters that are
2902recognized as white space in EBCDIC.
2903
290445. When PCRE2 was compiled without Unicode support, the use of \p and \P gave
2905an error (correctly) when used outside a class, but did not give an error
2906within a class.
2907
290846. \h within a class was incorrectly compiled in EBCDIC environments.
2909
291047. JIT should return with error when the compiled pattern requires
2911more stack space than the maximum.
2912
291348. Fixed a memory leak in pcre2grep when a locale is set.
2914
2915
2916Version 10.10 06-March-2015
2917---------------------------
2918
29191. When a pattern is compiled, it remembers the highest back reference so that
2920when matching, if the ovector is too small, extra memory can be obtained to
2921use instead. A conditional subpattern whose condition is a check on a capture
2922having happened, such as, for example in the pattern /^(?:(a)|b)(?(1)A|B)/, is
2923another kind of back reference, but it was not setting the highest
2924backreference number. This mattered only if pcre2_match() was called with an
2925ovector that was too small to hold the capture, and there was no other kind of
2926back reference (a situation which is probably quite rare). The effect of the
2927bug was that the condition was always treated as FALSE when the capture could
2928not be consulted, leading to a incorrect behaviour by pcre2_match(). This bug
2929has been fixed.
2930
29312. Functions for serialization and deserialization of sets of compiled patterns
2932have been added.
2933
29343. The value that is returned by PCRE2_INFO_SIZE has been corrected to remove
2935excess code units at the end of the data block that may occasionally occur if
2936the code for calculating the size over-estimates. This change stops the
2937serialization code copying uninitialized data, to which valgrind objects. The
2938documentation of PCRE2_INFO_SIZE was incorrect in stating that the size did not
2939include the general overhead. This has been corrected.
2940
29414. All code units in every slot in the table of group names are now set, again
2942in order to avoid accessing uninitialized data when serializing.
2943
29445. The (*NO_JIT) feature is implemented.
2945
29466. If a bug that caused pcre2_compile() to use more memory than allocated was
2947triggered when using valgrind, the code in (3) above passed a stupidly large
2948value to valgrind. This caused a crash instead of an "internal error" return.
2949
29507. A reference to a duplicated named group (either a back reference or a test
2951for being set in a conditional) that occurred in a part of the pattern where
2952PCRE2_DUPNAMES was not set caused the amount of memory needed for the pattern
2953to be incorrectly calculated, leading to overwriting.
2954
29558. A mutually recursive set of back references such as (\2)(\1) caused a
2956segfault at compile time (while trying to find the minimum matching length).
2957The infinite loop is now broken (with the minimum length unset, that is, zero).
2958
29599. If an assertion that was used as a condition was quantified with a minimum
2960of zero, matching went wrong. In particular, if the whole group had unlimited
2961repetition and could match an empty string, a segfault was likely. The pattern
2962(?(?=0)?)+ is an example that caused this. Perl allows assertions to be
2963quantified, but not if they are being used as conditions, so the above pattern
2964is faulted by Perl. PCRE2 has now been changed so that it also rejects such
2965patterns.
2966
296710. The error message for an invalid quantifier has been changed from "nothing
2968to repeat" to "quantifier does not follow a repeatable item".
2969
297011. If a bad UTF string is compiled with NO_UTF_CHECK, it may succeed, but
2971scanning the compiled pattern in subsequent auto-possessification can get out
2972of step and lead to an unknown opcode. Previously this could have caused an
2973infinite loop. Now it generates an "internal error" error. This is a tidyup,
2974not a bug fix; passing bad UTF with NO_UTF_CHECK is documented as having an
2975undefined outcome.
2976
297712. A UTF pattern containing a "not" match of a non-ASCII character and a
2978subroutine reference could loop at compile time. Example: /[^\xff]((?1))/.
2979
298013. The locale test (RunTest 3) has been upgraded. It now checks that a locale
2981that is found in the output of "locale -a" can actually be set by pcre2test
2982before it is accepted. Previously, in an environment where a locale was listed
2983but would not set (an example does exist), the test would "pass" without
2984actually doing anything. Also the fr_CA locale has been added to the list of
2985locales that can be used.
2986
298714. Fixed a bug in pcre2_substitute(). If a replacement string ended in a
2988capturing group number without parentheses, the last character was incorrectly
2989literally included at the end of the replacement string.
2990
299115. A possessive capturing group such as (a)*+ with a minimum repeat of zero
2992failed to allow the zero-repeat case if pcre2_match() was called with an
2993ovector too small to capture the group.
2994
299516. Improved error message in pcre2test when setting the stack size (-S) fails.
2996
299717. Fixed two bugs in CMakeLists.txt: (1) Some lines had got lost in the
2998transfer from PCRE1, meaning that CMake configuration failed if "build tests"
2999was selected. (2) The file src/pcre2_serialize.c had not been added to the list
3000of PCRE2 sources, which caused a failure to build pcre2test.
3001
300218. Fixed typo in pcre2_serialize.c (DECL instead of DEFN) that causes problems
3003only on Windows.
3004
300519. Use binary input when reading back saved serialized patterns in pcre2test.
3006
300720. Added RunTest.bat for running the tests under Windows.
3008
300921. "make distclean" was not removing config.h, a file that may be created for
3010use with CMake.
3011
301222. A pattern such as "((?2){0,1999}())?", which has a group containing a
3013forward reference repeated a large (but limited) number of times within a
3014repeated outer group that has a zero minimum quantifier, caused incorrect code
3015to be compiled, leading to the error "internal error: previously-checked
3016referenced subpattern not found" when an incorrect memory address was read.
3017This bug was reported as "heap overflow", discovered by Kai Lu of Fortinet's
3018FortiGuard Labs. (Added 24-March-2015: CVE-2015-2325 was given to this.)
3019
302023. A pattern such as "((?+1)(\1))/" containing a forward reference subroutine
3021call within a group that also contained a recursive back reference caused
3022incorrect code to be compiled. This bug was reported as "heap overflow",
3023discovered by Kai Lu of Fortinet's FortiGuard Labs. (Added 24-March-2015:
3024CVE-2015-2326 was given to this.)
3025
302624. Computing the size of the JIT read-only data in advance has been a source
3027of various issues, and new ones are still appear unfortunately. To fix
3028existing and future issues, size computation is eliminated from the code,
3029and replaced by on-demand memory allocation.
3030
303125. A pattern such as /(?i)[A-`]/, where characters in the other case are
3032adjacent to the end of the range, and the range contained characters with more
3033than one other case, caused incorrect behaviour when compiled in UTF mode. In
3034that example, the range a-j was left out of the class.
3035
3036
3037Version 10.00 05-January-2015
3038-----------------------------
3039
3040Version 10.00 is the first release of PCRE2, a revised API for the PCRE
3041library. Changes prior to 10.00 are logged in the ChangeLog file for the old
3042API, up to item 20 for release 8.36.
3043
3044The code of the library was heavily revised as part of the new API
3045implementation. Details of each and every modification were not individually
3046logged. In addition to the API changes, the following changes were made. They
3047are either new functionality, or bug fixes and other noticeable changes of
3048behaviour that were implemented after the code had been forked.
3049
30501. Including Unicode support at build time is now enabled by default, but it
3051can optionally be disabled. It is not enabled by default at run time (no
3052change).
3053
30542. The test program, now called pcre2test, was re-specified and almost
3055completely re-written. Its input is not compatible with input for pcretest.
3056
30573. Patterns may start with (*NOTEMPTY) or (*NOTEMPTY_ATSTART) to set the
3058PCRE2_NOTEMPTY or PCRE2_NOTEMPTY_ATSTART options for every subject line that is
3059matched by that pattern.
3060
30614. For the benefit of those who use PCRE2 via some other application, that is,
3062not writing the function calls themselves, it is possible to check the PCRE2
3063version by matching a pattern such as /(?(VERSION>=10)yes|no)/ against a
3064string such as "yesno".
3065
30665. There are case-equivalent Unicode characters whose encodings use different
3067numbers of code units in UTF-8. U+023A and U+2C65 are one example. (It is
3068theoretically possible for this to happen in UTF-16 too.) If a backreference to
3069a group containing one of these characters was greedily repeated, and during
3070the match a backtrack occurred, the subject might be backtracked by the wrong
3071number of code units. For example, if /^(\x{23a})\1*(.)/ is matched caselessly
3072(and in UTF-8 mode) against "\x{23a}\x{2c65}\x{2c65}\x{2c65}", group 2 should
3073capture the final character, which is the three bytes E2, B1, and A5 in UTF-8.
3074Incorrect backtracking meant that group 2 captured only the last two bytes.
3075This bug has been fixed; the new code is slower, but it is used only when the
3076strings matched by the repetition are not all the same length.
3077
30786. A pattern such as /()a/ was not setting the "first character must be 'a'"
3079information. This applied to any pattern with a group that matched no
3080characters, for example: /(?:(?=.)|(?<!x))a/.
3081
30827. When an (*ACCEPT) is triggered inside capturing parentheses, it arranges for
3083those parentheses to be closed with whatever has been captured so far. However,
3084it was failing to mark any other groups between the highest capture so far and
3085the current group as "unset". Thus, the ovector for those groups contained
3086whatever was previously there. An example is the pattern /(x)|((*ACCEPT))/ when
3087matched against "abcd".
3088
30898. The pcre2_substitute() function has been implemented.
3090
30919. If an assertion used as a condition was quantified with a minimum of zero
3092(an odd thing to do, but it happened), SIGSEGV or other misbehaviour could
3093occur.
3094
309510. The PCRE2_NO_DOTSTAR_ANCHOR option has been implemented.
3096
3097****
3098