summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2013-11-18 05:45:19 -0800
committerFather Chrysostomos <sprout@cpan.org>2013-11-18 08:29:32 -0800
commit07ea66ee50a792fecf5f54f3f88cc62bde883722 (patch)
treef8ad96cf742530fda8992435320204a46fedd3cf
parent2739ead2faefd38cc7d3c6d373372c2a8755ed3b (diff)
downloadperl-07ea66ee50a792fecf5f54f3f88cc62bde883722.tar.gz
Require closing paren for (?&...
$ ./perl -Ilib -le 'print "aaz" =~ /(?<a>a)(?&a-z/' a (?&name) was actually allowing any non-word character to terminate it.
-rw-r--r--pod/perldiag.pod7
-rw-r--r--regcomp.c2
-rw-r--r--t/re/reg_mesg.t3
3 files changed, 11 insertions, 1 deletions
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index bdf8c5509b..7c0d8d4d26 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -4776,6 +4776,13 @@ causes, see L<perlre>.
parenthesis. Embedded parentheses aren't allowed. See
L<perlre>.
+=item Sequence (?&... not terminated in regex; marked by S<<-- HERE> in
+m/%s/
+
+(F) A named reference of the form C<(?&...)> was missing the final
+closing parenthesis after the name. The S<<-- HERE> shows whereabouts
+in the regular expression the problem was discovered.
+
=item Sequence (?%c... not terminated in regex; marked by S<<-- HERE>
in m/%s/
diff --git a/regcomp.c b/regcomp.c
index 1b3c04d4d6..7df57670c0 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -9350,6 +9350,8 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp,U32 depth)
SIZE_ONLY ? REG_RSN_RETURN_NULL : REG_RSN_RETURN_DATA);
num = sv_dat ? *((I32 *)SvPVX(sv_dat)) : 0;
}
+ if (RExC_parse == RExC_end || *RExC_parse != ')')
+ vFAIL("Sequence (?&... not terminated");
goto gen_recurse_regop;
assert(0); /* NOT REACHED */
case '+':
diff --git a/t/re/reg_mesg.t b/t/re/reg_mesg.t
index 0835ce7869..f81d8b6ba3 100644
--- a/t/re/reg_mesg.t
+++ b/t/re/reg_mesg.t
@@ -212,7 +212,8 @@ my @death =
'm/\87/' => 'Reference to nonexistent group {#} m/\87{#}/',
'm/a\87/' => 'Reference to nonexistent group {#} m/a\87{#}/',
'm/a\97/' => 'Reference to nonexistent group {#} m/a\97{#}/',
- 'm/(*DOOF)/' => 'Unknown verb pattern \'DOOF\' {#} m/(*DOOF){#}/'
+ 'm/(*DOOF)/' => 'Unknown verb pattern \'DOOF\' {#} m/(*DOOF){#}/',
+ 'm/(?&a/' => 'Sequence (?&... not terminated {#} m/(?&a{#}/',
);
my @death_utf8 = mark_as_utf8(