summaryrefslogtreecommitdiff
path: root/backport-Improve-error-message-for-N-name-in-character-classes.patch
diff options
context:
space:
mode:
Diffstat (limited to 'backport-Improve-error-message-for-N-name-in-character-classes.patch')
-rw-r--r--backport-Improve-error-message-for-N-name-in-character-classes.patch68
1 files changed, 68 insertions, 0 deletions
diff --git a/backport-Improve-error-message-for-N-name-in-character-classes.patch b/backport-Improve-error-message-for-N-name-in-character-classes.patch
new file mode 100644
index 0000000..8ad59b9
--- /dev/null
+++ b/backport-Improve-error-message-for-N-name-in-character-classes.patch
@@ -0,0 +1,68 @@
+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 @@
+
+ /\N{25,ab}/
+
++/[\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,
+ /\N{25,ab}/
+ 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