Releases: mudge/re2
2.1.3: Fixed memory leaks with invalid inputs
Fixed memory leaks reported by ruby_memcheck when rewinding an RE2::Scanner
and when passing invalid input to RE2::Regexp#scan
, RE2::Regexp#initialize
, RE2.Replace
, RE2.GlobalReplace
and RE2::Set#add
.
Thanks to @peterzhu2118 for maintaining ruby_memcheck and their assistance in finding the source of these leaks.
SHA256 checksums:
27316bb47cfc0f28cfd1626426120e1c55ca8420a64c9e966f8feb1c911eae2a re2-2.1.3-aarch64-linux.gem
81ffdd76b202f24461b4868abed96c994e2106e57970004b841499da983f688c re2-2.1.3-arm-linux.gem
86d553e85779943a353865cbfdd89156c0411b92a1c7fe6abf1024135d53190e re2-2.1.3-arm64-darwin.gem
be0277c15bef6f38a2f9805aca798de4a31f6319cb1790ff6683112cb89721da re2-2.1.3-x64-mingw-ucrt.gem
cadba41d90f2186507c97593084b8f951c9c3ee7ecb2be02f3497aa9c5cdaadb re2-2.1.3-x64-mingw32.gem
ad54cafdaf40310cf3aab485697b997718c573d6a780f802c3faab7a38119623 re2-2.1.3-x86-linux.gem
6bfa3c1c119b485375688a9c90c0b8cfc03991495c2e4d50accb6bbcd406c186 re2-2.1.3-x86-mingw32.gem
513b12c5b7536c65e80ddb2a7eee0dbbefea534d6352e9470040016c547f90a5 re2-2.1.3-x86_64-darwin.gem
73a2e20fc1dc7b2773d2862ec061e545f6820643486c0d69e3ad40de19ce5c0b re2-2.1.3-x86_64-linux.gem
03a30b53002ab66b66fa2d4500c82ec0866020c22e11c23516f660ce43cfae8f re2-2.1.3.gem
2.1.2: Restore support for non-C++17 compilers
Some of the C++ changes in 2.1.1 involved a C++17 extension: 'if' initialization statements (e.g. if (bool foo = bar; bar != baz) {
which meant the gem would only compile with a C++ compiler that supported that version of the language.
As users may be compiling against older versions of RE2 that only require C++11, remove this extension from the codebase to restore support for this use case.
SHA256 checksums:
dbd87fb2432f17734cfb948d38cb0d138335228d31c4316719c75ac0a976731f re2-2.1.2-aarch64-linux.gem
4c0d903508bc0d82f27d09c84498e0fdc6ab87ef418bea884d711b85f7fca62f re2-2.1.2-arm-linux.gem
39bb8a44a4afbd2d3f2e07d531d223728f7c4b83946bc55e8ce6aae8c2c34579 re2-2.1.2-arm64-darwin.gem
a1ad9cda576dae6020664c7578d7e43d2062ca21e5e945aea125f539944ee713 re2-2.1.2-x64-mingw-ucrt.gem
804fc9bafc6590e3e75d27d289546d7223b51bf3e46e9d81ee89cf5168c1a9be re2-2.1.2-x64-mingw32.gem
6a048f8a1511a5481f7a386045e67ecbb221a856d2987b33a231efb5e17250bc re2-2.1.2-x86-linux.gem
8e0e9d0f3166ff3000ffa38a05c9e5275ba431f2abce494fa7600033206ce108 re2-2.1.2-x86-mingw32.gem
6b41f328b551173e58eb04320c70295de143b5aeb38c78122aa623a4308bc472 re2-2.1.2-x86_64-darwin.gem
e082a1db722b7da3adc9e1f9d8681cba80a2d1176c54ae741443965ce277e6af re2-2.1.2-x86_64-linux.gem
06bd25bf566dda720cbc607ceecb65ed16871427fbcb3e5239c300ec796fee9c re2-2.1.2.gem
2.1.1: Fix deprecation warning when compiling with recent Ruby versions
This is a patch release with no API or behaviour changes, only internal cleanup. Specifically:
- Worked around a deprecation warning re the use of
ANYARGS
when compiling against recent Ruby versions. - Various internal C++ style improvements to reduce unnecessary memory usage when accessing named capturing groups.
SHA256 checksums:
ddfdda8c21d9fec6ca2ed7cd24924dd8be8bac5d50e5cc04ee193664edf00f2e re2-2.1.1-aarch64-linux.gem
e14055ece43625e7dede7bf2b28fa9af9c3e14c9c6396d5a177ac06abbb7aedf re2-2.1.1-arm-linux.gem
929072d08921ec1fa07cd4325283c0289e066ab8e68f1ac696e9a47e2a95557a re2-2.1.1-arm64-darwin.gem
6d029ea31d9f2818820cbf95f61b9f33c60ac33335db11951c98bebdb731618f re2-2.1.1-x64-mingw-ucrt.gem
cde04e7ee4db4b17b2eee92e5cb0cf85376d4bcce143ba050c8f07f98a6feb89 re2-2.1.1-x64-mingw32.gem
089d9a96919a8917647a6763e9152c1a359f6bb7b0e0297ec931613d733408d5 re2-2.1.1-x86-linux.gem
c16ee7896dd12ef032fca0c0d34769df42c41754dc0c04fc840c61f3292c409b re2-2.1.1-x86-mingw32.gem
17883c31d7612d022856236ba08086a61e457132cde14601b235718db347be5f re2-2.1.1-x86_64-darwin.gem
4e5cf4fc5ebd2118c0b9a64e3910b1017b81989efd29c4cbffa6ca5080115cd4 re2-2.1.1-x86_64-linux.gem
28822653610645d6deb9b251dd57bd0bc0639d293e615f7f4fda8b91bea85c98 re2-2.1.1.gem
2.1.0: Fix encoding inconsistencies & accept String-like inputs with RE2::Set
As RE2 only supports UTF-8 and ISO-8859-1 encodings, fix an inconsistency when using string patterns with RE2.Replace
and RE2.GlobalReplace
where the result would match the encoding of the pattern rather than UTF-8 which is what RE2 will use. This behaviour and limitation is now documented on all APIs that produce string results.
e.g.
# With re2 2.0.0
RE2.Replace("Hello World", "Hello".encode("Windows-1250"), "Hi").encoding
# => #<Encoding:Windows-1250>
# With re2 2.1.0
RE2.Replace("Hello World", "Hello".encode("Windows-1250"), "Hi").encoding
# => #<Encoding:UTF-8>
Other changes
- The
RE2::Set
API now accepts anything that can be coerced to a string where previously only strings were permitted, e.g.RE2::Set#add
,RE2::Set#match
. - Added the licences of all vendored dependencies: RE2 and Abseil.
- Document the behaviour of
RE2::Regexp#match
when given a pattern with no capturing groups: it will return true or false whether there was a match or not rather than aRE2::MatchData
instance.
SHA256 checksums:
b25780558d879c9b2be62f1bd2e4c25a1b5b8bddc31d1cd54253228abb7a8fa5 re2-2.1.0-aarch64-linux.gem
d2be264d95c43877110a859e81aacc6cb6672b9247341f82b45d543317464c58 re2-2.1.0-arm-linux.gem
fac207639de2efae9640443f1a043cbd09f66d74f03ee7c01e033edbf1ef80a2 re2-2.1.0-arm64-darwin.gem
50c2931c183fa92bf3285c88a82fefd640d4eb2b639af305122c7f84aefe431f re2-2.1.0-x64-mingw-ucrt.gem
d781eb47a25d1dd363a4eab06b012388ea19d5251a1cb0ee766a54df1b5d0b01 re2-2.1.0-x64-mingw32.gem
3ffad83e899d920a6c4f45476c3c12c29d60d20c483573c01844ab3616fc826a re2-2.1.0-x86-linux.gem
f9ffb84be1b37b20af5f9a5aefbe49714b20ce6b65a34563af360a4bb73fabca re2-2.1.0-x86-mingw32.gem
125c228d3760f3f837c17aa8edc9526a474cd5c7086febead6545050af5d757b re2-2.1.0-x86_64-darwin.gem
cabb3ee256ecb70fd4cbfde6d7f6f5062670b6d21191f5ff48404e1054cbb8eb re2-2.1.0-x86_64-linux.gem
54a3e42bd3860b915c35df6024fb8634442d780ce4c31ccc92506a62151618ae re2-2.1.0.gem
2.0.0: vendored RE2 2023-09-01 & native gems
This is a major new version of re2 which no longer requires the RE2 library to be installed as the latest version (2023-09-01) is now vendored with the gem.
Vendored RE2
Installing the gem will also compile and install RE2 (and its dependency, Abseil). As this can take some time, precompiled native gems are available for the following platforms meaning there’s no need to wait for compilation in the majority of cases:
aarch64-linux
(requires: glibc >= 2.29)arm-linux
(requires: glibc >= 2.29)arm64-darwin
x64-mingw32
/x64-mingw-ucrt
x86-linux
(requires: glibc >= 2.17)x86_64-darwin
x86_64-linux
(requires: glibc >= 2.17)
Breaking changes
Due to a new dependency on MiniPortile2 and the need to include compiled C extensions for every supported version of Ruby in the native gems, this major version drops support for all Ruby versions prior to 2.6.
Opting out of the vendored RE2
To opt out of using the gem’s vendored dependencies and instead rely on the previous behaviour of linking against a system install of RE2, use the --enable-system-libraries
option when installing the gem.
Note you’ll also need to use the ruby
platform to avoid the native gems either via gem install re2 --platform=ruby -- --enable-system-libraries
or Bundler's force_ruby_platform
option.
Thanks
This major release would not have happened without @stanhu.
SHA256 checksums:
677ddce4c38d659de899651acbfd7c6b5331f984a7101d9179ac247284f2212a re2-2.0.0-aarch64-linux.gem
f657d689922e5ac215b486e4f2ca909f1079eab616269a1d8fc0cccd63ef28af re2-2.0.0-arm-linux.gem
ffc8e5663381ff344ee6a2e55c7d0be81ef9b43174a41e977c4e18a11f965be1 re2-2.0.0-arm64-darwin.gem
253b3de21ca563cdb93c9fd69738a2a66713e381bae4530ff2cae105c6fd1a8e re2-2.0.0-x64-mingw-ucrt.gem
d4b52fc21719f262c2a438912f009da868b31aed1688ec90e4e1696898fb53d3 re2-2.0.0-x64-mingw32.gem
26abee219e3fd69ba5c6a7bdb882880b8af6502cf912da7a7837e38ad02a29e7 re2-2.0.0-x86-linux.gem
ffec6da4c547e44a6c1a467b0b01b2dcc2940e081923221a2ac3e4b08a219c26 re2-2.0.0-x86-mingw32.gem
48b3ba3fea8cc84709a4195300cd1c627b2496f16e5865662c54e67f7aca1ccf re2-2.0.0-x86_64-darwin.gem
1fb161e6e5d9efed59ed0062536f2cb9ab5fba367e209d0dc66f99f2864d42ff re2-2.0.0-x86_64-linux.gem
09075fab88b7ab40c2374d75a20504408dc26539c11931b146d5f72892718925 re2-2.0.0.gem
2.0.0.beta2: RE2 2023-09-01, fix for compiling against system RE2 & Ruby 2.6 support
Please install this release with gem install re2 --pre
and report any issues you find.
Fixes since beta1
- Upgraded the vendored RE2 to the latest version: 2023-09-01.
- @stanhu fixed a problem when opting out of the precompiled, native gems and compiling the gem against a system RE2 that also happens to be Ruby’s default
exec_prefix
directory. - We’ve restored support for Ruby 2.6 and that is now included in the native gems meaning the gem can be installed against the default system Ruby on macOS Monterey.
2.0.0.beta1: vendor RE2, native gems
Thanks to @stanhu: this is the first beta release of a major new version of re2 which no longer requires the RE2 library to be installed as it is now vendored with the gem (ala Nokogiri and libxml2).
Installing the gem will also compile and install RE2 (and its dependency, abseil). As this can take some time, precompiled native gems are available for major platforms meaning there’s no need to wait for compilation.
Due to a new dependency on MiniPortile2 and the need to include compiled C extensions for every supported version of Ruby in the native gems, this major version drops support for all Ruby versions prior to 2.7, matching Nokogiri’s policy of supporting the last 4 minor versions of Ruby (2.7, 3.0, 3.1 and 3.2).
To opt out of using the gem’s vendored dependencies and instead rely on the previous behaviour of linking against a system install of RE2, use the --enable-system-libraries
option when installing the gem (note you’ll need to use the ruby
platform to avoid the native gems too).
Known issues
- Installing and compiling the
ruby
platform gem (i.e. not one of the precompiled native gems) with the bundled dependencies on a system which has its own RE2 library installed in Ruby’s defaultexec_path
will link incorrectly, see #93
1.7.0: re2 2023-07-01 support
Thanks to @stanhu for adding support for the latest version of re2—2023-07-01—which now depends on Abseil and therefore requires a compiler with C++14 support or newer.
1.6.0: Pattern matching RE2::MatchData
In order to support pattern matching in recent versions of Ruby, implement RE2::MatchData#deconstruct
and RE2::MatchData#deconstruct_keys
. This allows matches to be matched with both array and hash patterns, e.g.
case RE2('(\w+) (\d+)').match("Alice 42")
in [name, age]
puts "My name is #{name} and I am #{age} years old"
else
puts "No match!"
end
# My name is Alice and I am 42 years old
case RE2('(?P<name>\w+) (?P<age>\d+)').match("Alice 42")
in {name:, age:}
puts "My name is #{name} and I am #{age} years old"
else
puts "No match!"
end
# My name is Alice and I am 42 years old
This is inspired by ruby/ruby#6216. Thanks to @tomstuart for drawing my attention to it.
1.5.0: Add RE2::Set for searching a collection of patterns simultaneously
Contributed by @pritambaral, add RE2::Set
representing a collection of patterns that can be searched for simultaneously.
Patterns are added to a set with RE2::Set#add
—returning the index of the pattern in the set—and then compiled with RE2::Set#compile
. Calling RE2::Set#match
with text will return an array of integer indices of matching patterns, e.g.
set = RE2::Set.new
set.add("abc") #=> 0
set.add("def") #=> 1
set.add("ghi") #=> 2
set.compile #=> true
set.match("abcdefghi") #=> [0, 1, 2]
set.match("ghidefabc") #=> [2, 1, 0]
Depending on the ABI version of the underlying re2 library, RE2::Set#match
will raise exceptions if there are any errors when matching. For ABI version 0, no error information is output so RE2::Set#match
can be passed an :exception
option of false
to silently return an empty array if there are any errors, e.g.
set = RE2::Set.new
set.match("abcdef", exception: false) #=> []