pcre2/backport-Fix-an-invalid-match-of-ascii-word-classes-when-inva.patch
2023-06-26 22:19:09 +08:00

42 lines
1.6 KiB
Diff

From 2c08b619dc973beacc474dcb67cda8cd366200ce Mon Sep 17 00:00:00 2001
From: Zoltan Herczeg <hzmester@freemail.hu>
Date: Tue, 11 Apr 2023 12:42:11 +0000
Subject: [PATCH] Fix an invalid match of ascii word classes when invalid utf
is enabled
Fixes #224
Conflict:delete changelog
Reference:https://github.com/PCRE2Project/pcre2/commit/2c08b619dc973beacc474dcb67cda8cd366200ce
---
src/pcre2_jit_compile.c | 1 +
src/pcre2_jit_test.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/src/pcre2_jit_compile.c b/src/pcre2_jit_compile.c
index 75ba610..81b7a93 100644
--- a/src/pcre2_jit_compile.c
+++ b/src/pcre2_jit_compile.c
@@ -4132,6 +4132,7 @@ if (negated)
if (common->invalid_utf)
{
+ OP1(SLJIT_MOV, TMP1, 0, TMP2, 0);
add_jump(compiler, &common->utfreadchar_invalid, JUMP(SLJIT_FAST_CALL));
add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, INVALID_UTF_CHAR));
OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);
diff --git a/src/pcre2_jit_test.c b/src/pcre2_jit_test.c
index e1f0bbc..1a1f6c5 100644
--- a/src/pcre2_jit_test.c
+++ b/src/pcre2_jit_test.c
@@ -1979,6 +1979,7 @@ static const struct invalid_utf8_regression_test_case invalid_utf8_regression_te
{ PCRE2_UTF, CI, 0, 0, 0, 7, 11, { "#\xc7\x85#", NULL }, "\x80\x80#\xc7\x80\x80\x80#\xc7\x85#" },
{ PCRE2_UTF | PCRE2_UCP, CI, 0, 0, 0, -1, -1, { "[\\s]", NULL }, "\xed\xa0\x80" },
+ { PCRE2_UTF, CI, 0, 0, 0, 1, 4, { "[\\D]", NULL }, "@\xe0\xab\xaa@" },
/* These two are not invalid UTF tests, but this infrastructure fits better for them. */
{ 0, PCRE2_JIT_COMPLETE, 0, 0, 1, -1, -1, { "\\X{2}", NULL }, "\r\n\n" },
--
2.27.0