diff options
author | Karl Williamson <khw@cpan.org> | 2020-02-15 17:39:00 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2020-02-19 22:09:48 -0700 |
commit | 4829f32decd128e6a122bd8ce35fe944bd87f104 (patch) | |
tree | b75fb15b5cc5c3321468801f5a12d212ab6f36de /op.h | |
parent | 809471154ccc09f339d9a2841b7c32c4aa9c40a2 (diff) | |
download | perl-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.h | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -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 |