14 Star 0 Fork 38

src-openEuler/pcre2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-Fix-z-behaviour-when-matching-within-invalid-UTF.patch 2.82 KB
一键复制 编辑 原始数据 按行查看 历史
From 05206d66340341bef7a673108a855f594c148950 Mon Sep 17 00:00:00 2001
From: Philip Hazel <[email protected]>
Date: Sun, 19 Nov 2023 18:32:10 +0000
Subject: [PATCH] Fix \z behaviour when matching within invalid UTF
---
src/pcre2_match.c | 6 ++++--
testdata/testinput10 | 3 +++
testdata/testinput12 | 3 +++
testdata/testoutput10 | 4 ++++
testdata/testoutput12-16 | 4 ++++
testdata/testoutput12-32 | 4 ++++
6 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/src/pcre2_match.c b/src/pcre2_match.c
index 2dcf8c4..ea03976 100644
--- a/src/pcre2_match.c
+++ b/src/pcre2_match.c
@@ -6076,10 +6076,12 @@ fprintf(stderr, "++ %2ld op=%3d %s\n", Fecode - mb->start_code, *Fecode,
if ((mb->poptions & PCRE2_DOLLAR_ENDONLY) == 0) goto ASSERT_NL_OR_EOS;
/* Fall through */
- /* Unconditional end of subject assertion (\z) */
+ /* Unconditional end of subject assertion (\z). We must check NOTEOL
+ because it gets set for invalid UTF fragments. */
case OP_EOD:
- if (Feptr < mb->end_subject) RRETURN(MATCH_NOMATCH);
+ if (Feptr < mb->end_subject || (mb->moptions & PCRE2_NOTEOL) != 0)
+ RRETURN(MATCH_NOMATCH);
if (mb->partial != 0)
{
mb->hitend = TRUE;
diff --git a/testdata/testinput10 b/testdata/testinput10
index c7618b1..e901d51 100644
--- a/testdata/testinput10
+++ b/testdata/testinput10
@@ -642,4 +642,7 @@
qchq\=ph
qchq\=ps
+/A\z/utf,match_invalid_utf
+ A\x80\x42\n
+
# End of testinput10
diff --git a/testdata/testinput12 b/testdata/testinput12
index 1e552e6..5a2d8d2 100644
--- a/testdata/testinput12
+++ b/testdata/testinput12
@@ -464,6 +464,9 @@
/aa/utf,ucp,match_invalid_utf,global
\x{d800}aa
+
+/A\z/utf,match_invalid_utf
+ A\x{df00}\n
# ----------------------------------------------------
diff --git a/testdata/testoutput10 b/testdata/testoutput10
index 18dd9d2..8145891 100644
--- a/testdata/testoutput10
+++ b/testdata/testoutput10
@@ -1921,4 +1921,8 @@ Partial match:
qchq\=ps
Partial match:
+/A\z/utf,match_invalid_utf
+ A\x80\x42\n
+No match
+
# End of testinput10
diff --git a/testdata/testoutput12-16 b/testdata/testoutput12-16
index 8cbc13d..9ac403e 100644
--- a/testdata/testoutput12-16
+++ b/testdata/testoutput12-16
@@ -1607,6 +1607,10 @@ No match
/aa/utf,ucp,match_invalid_utf,global
\x{d800}aa
0: aa
+
+/A\z/utf,match_invalid_utf
+ A\x{df00}\n
+No match
# ----------------------------------------------------
diff --git a/testdata/testoutput12-32 b/testdata/testoutput12-32
index 1a98b4b..9396305 100644
--- a/testdata/testoutput12-32
+++ b/testdata/testoutput12-32
@@ -1605,6 +1605,10 @@ No match
/aa/utf,ucp,match_invalid_utf,global
\x{d800}aa
0: aa
+
+/A\z/utf,match_invalid_utf
+ A\x{df00}\n
+No match
# ----------------------------------------------------
--
2.33.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/pcre2.git
[email protected]:src-openeuler/pcre2.git
src-openeuler
pcre2
pcre2
master

搜索帮助