Replace PCRE1 with PCRE2#4939
Open
Lpsd wants to merge 12 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the outdated PCRE1 with PCRE2 10.47 from https://github.com/PCRE2Project/pcre2
With the exception of a startup check in
Server/mods/deathmatch/logic/CGame.cpp, the only usage of PCRE is for the Lua implementation ofpregFind,pregMatchandpregReplacefunctions. A testing resource is provided below with 40 test cases.There is no C++ wrapper in PCRE2, so we now have our own under
Shared/pcrecpp_compat.hMotivation
PCRE1 is not maintained anymore
Test plan
Test resource: pcre.zip
Simply start the resource and all 40 tests will run with results output in console (server).
It's worth noting that 5 of the tests don't actually work with PCRE1, however they are resolved in PCRE2 -- or rather by the new C++ wrapper. This isn't a concern for backwards compatibility since these cases weren't working properly (or at all) previously.
pregFind"line1\nline2"/"^line2"/"m"truepregFind"a\nb"/"a.b"falsepregFind"Γειά"/"\w+"/"u"truepregMatch"John Doe"/"(\w+) (\w+)"{"John Doe"}pregReplace"a/b"/"/"/"\""a\b"pcrecppwrapper failed to passPCRE_MULTILINE/PCRE_DOTALLflags through topcre_compile. The C API supported them, but the C++ wrapper silently dropped them.set_utf8(true)only setPCRE_UTF8withoutPCRE_UCP, so\wmatched only ASCII even with UTF-8 enabled. Our compat wrapper correctly enables bothPCRE2_UTF+PCRE2_UCP.FindAndConsumereturned only the first capture group ("John") instead of the full match ("John Doe") for patterns with parenthesized groups.\for backreferences in replacement strings, causing a literal\to be consumed as an escape. PCRE2'spcre2_substituteuses$for backreferences, so literal\passes through correctly.Checklist