summaryrefslogtreecommitdiff
path: root/op.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2020-02-15 17:39:00 -0700
committerKarl Williamson <khw@cpan.org>2020-02-19 22:09:48 -0700
commit4829f32decd128e6a122bd8ce35fe944bd87f104 (patch)
treeb75fb15b5cc5c3321468801f5a12d212ab6f36de /op.h
parent809471154ccc09f339d9a2841b7c32c4aa9c40a2 (diff)
downloadperl-4829f32decd128e6a122bd8ce35fe944bd87f104.tar.gz
Restrict features in wildcards
The algorithm for dealing with Unicode property wildcards is to wrap the user-supplied pattern with /miaa. We don't want the user to be able to override the /m and /aa parts. Modifiers that are only specifiable as a modifier in a qr or similar op (like /gc) can't be included in things like (?gc). These normally incur a warning that they are ignored, but the texts of those warnings are misleading when using wildcards, so I chose to just make them illegal. Of course that could be changed to having custom useful warning texts, but I didn't think it was worth it. I also chose to forbid recursion of using nested \p{}, just from fear that it might lead to issues down the road, and it really isn't useful for this limited universe of strings to match against. Because wildcards currently can't handle '}' inside them, only the single letter \p,\P are valid anyway. Similarly, I forbid the '*' quantifier to make it harder for the constructed subpattern to take forever to make any progress and decide to halt. Again, using it would be overkill on the universe of possible match strings.
Diffstat (limited to 'op.h')
-rw-r--r--op.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/op.h b/op.h
index 4a544d979c..cbb19d557a 100644
--- a/op.h
+++ b/op.h
@@ -372,6 +372,10 @@ struct pmop {
#define PMf_IS_QR (1U<<(PMf_BASE_SHIFT+15))
#define PMf_USE_RE_EVAL (1U<<(PMf_BASE_SHIFT+16)) /* use re'eval' in scope */
+/* Means that this is a subpattern being compiled while processing a \p{}
+ * wildcard. This isn't called from op.c, but it is passed as a pm flag. */
+#define PMf_WILDCARD (1U<<(PMf_BASE_SHIFT+17))
+
/* See comments at the beginning of these defines about adding bits. The
* highest bit position should be used, so that if PMf_BASE_SHIFT gets
* increased, the #error below will be triggered so that you will be reminded