Skip to content

RE2/J 1.9

Latest

Choose a tag to compare

@eamonnmcmanus eamonnmcmanus released this 25 Nov 21:56
3c8a8fb

This release includes fixes for issues that could cause heap exhaustion (#216) or infinite looping (#168).

  • Prevent heap exhaustion (OOM) on nested counted repetitions (#219, fixes #216): Pattern.compile() previously had no bound on the total size of the compiled program, allowing short untrusted patterns with nested counted repetitions to exhaust the JVM heap (analogous to Go's CVE-2022-41715). Compiler now caps compiled programs at 500,000 instructions and throws PatternSyntaxException("expression too large") when exceeded.
  • Prevent infinite loop in case-insensitive matching on asymmetric Unicode case mappings (#213, fixes #168; follow-up in #220): On JDK 9+, Unicode.simpleFold() could enter an infinite loop during Pattern.compile() or matching for (?i) patterns containing certain Unicode 9.0+ characters with asymmetric case mappings (e.g., U+1C80..U+1C88) not present in the static fold tables. simpleFold() now only follows symmetric fallback mappings (and bounds the fallback to <= Unicode.MAX_FOLD outside CASE_ORBIT), guaranteeing termination.

The released jar now includes Automatic-Module-Name: com.google.re2j.

The API now includes JSpecify nullness annotations.

What's Changed in detail

  • update setup-java github action by @sjamesr in #203
  • Add JSpecify annotations to the API. by @eamonnmcmanus in #210
  • Reset Matcher state on match failure by @cushon in #205
  • Fix appendReplacement validation by @cushon in #204
  • Fix handling of split when the input is fully matched and the limit is 0 by @cushon in #202
  • Cap compiled program size to prevent OOM on nested repetitions. by @eamonnmcmanus in #219
  • Make simpleFold follow only symmetric case mappings. by @jemmix in #213
  • Bound simpleFold fallback to MAX_FOLD and non-CASE_ORBIT runes. by @eamonnmcmanus in #220
  • Compare FoldCase in Regexp.equals/hashCode for LITERAL/CHAR_CLASS. by @jemmix in #212
  • Fix literal-prefix search starting inside surrogate pairs. by @jemmix in #208
  • Fixed asymmetric behavior for case-insensitive matches by @raipc in #199
  • MachineInput: fix bug: byte treated as unsigned by @kitbellew in #193
  • Add unit test for UTF8Input.context after multibyte UTF-8 characters. by @eamonnmcmanus in #222
  • ApiTestUtils: fix typo in test, use intended input by @kitbellew in #192
  • RE2: avoid an extra copy of the groups array by @kitbellew in #188
  • Allow unescaped '$' in Matcher.appendReplacement when not a group reference by @eamonnmcmanus in #223
  • Add Automatic-Module-Name to the JAR manifest. by @eamonnmcmanus in #225

New Contributors

Full Changelog: re2j-1.8...re2j-1.9