14 Star 0 Fork 38

src-openEuler/pcre2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-Improve-error-message-for-N-name-in-character-classes.patch 1.84 KB
一键复制 编辑 原始数据 按行查看 历史
markeryang 提交于 2024-11-19 17:16 +08:00 . sync backport patches from upstream
From d704ee40c5324e5ff6c08f009a7aaa3b67b71565 Mon Sep 17 00:00:00 2001
From: Nicholas Wilson <niwilson@microsoft.com>
Date: Fri, 27 Sep 2024 16:31:01 +0100
Subject: [PATCH] Improve error message for \N{name} in character classes
(#502)
---
src/pcre2_compile.c | 8 ++++++++
testdata/testinput2 | 6 ++++++
testdata/testoutput2 | 9 +++++++++
3 files changed, 23 insertions(+)
diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c
index ec4940e63..fd554f1d2 100644
--- a/src/pcre2_compile.c
+++ b/src/pcre2_compile.c
@@ -1542,6 +1542,14 @@ else if ((i = escapes[c - ESCAPES_FIRST]) != 0)
#endif
}
+ /* Give an error in contexts where quantifiers are not allowed
+ (character classes; substitution strings). */
+
+ else if (isclassorsub || cb == NULL)
+ {
+ *errorcodeptr = ERR37;
+ }
+
/* Give an error if what follows is not a quantifier, but don't override
an error set by the quantifier reader (e.g. number overflow). */
diff --git a/testdata/testinput2 b/testdata/testinput2
index c6ee980..a33d987 100644
--- a/testdata/testinput2
+++ b/testdata/testinput2
@@ -913,6 +913,12 @@
/\U/I
+/[\N]/
+
+/[\N{4}]/
+
+/[\N{name}]/
+
/a{1,3}b/ungreedy
ab
diff --git a/testdata/testoutput2 b/testdata/testoutput2
index 2f2b3d1..4c07b72 100644
--- a/testdata/testoutput2
+++ b/testdata/testoutput2
@@ -3245,6 +3245,15 @@ Failed: error 137 at offset 2: PCRE2 does not support \F, \L, \l, \N{name}, \U,
/\U/I
Failed: error 137 at offset 2: PCRE2 does not support \F, \L, \l, \N{name}, \U, or \u
+/[\N]/
+Failed: error 171 at offset 3: \N is not supported in a class
+
+/[\N{4}]/
+Failed: error 137 at offset 3: PCRE2 does not support \F, \L, \l, \N{name}, \U, or \u
+
+/[\N{name}]/
+Failed: error 137 at offset 3: PCRE2 does not support \F, \L, \l, \N{name}, \U, or \u
+
/a{1,3}b/ungreedy
ab
0: ab
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/pcre2.git
git@gitee.com:src-openeuler/pcre2.git
src-openeuler
pcre2
pcre2
master

搜索帮助