From ce4bd586d8b371561718e129c4f41aa75850780e Mon Sep 17 00:00:00 2001 From: Brian Fraser Date: Thu, 29 Aug 2013 11:36:12 -0300 Subject: [PATCH] regcomp.c, S_compile_runtime_code: croak using the SVf format This makes error messages from code like this: $f = "(?{q\0foo\0 + \x{FFFF}})"; "a" =~ /^a$f/; Be both UTF-8 and nul clean. --- regcomp.c | 2 +- t/re/pat_re_eval.t | 7 ++++++- t/uni/parser.t | 4 +--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/regcomp.c b/regcomp.c index 931f8fb..1dde851 100644 --- a/regcomp.c +++ b/regcomp.c @@ -5353,7 +5353,7 @@ S_compile_runtime_code(pTHX_ RExC_state_t * const pRExC_state, { Safefree(pRExC_state->code_blocks); /* use croak_sv ? */ - Perl_croak_nocontext("%s", SvPV_nolen_const(errsv)); + Perl_croak_nocontext("%"SVf, SVfARG(errsv)); } } assert(SvROK(qr_ref)); diff --git a/t/re/pat_re_eval.t b/t/re/pat_re_eval.t index e47aaf3..14d681a 100644 --- a/t/re/pat_re_eval.t +++ b/t/re/pat_re_eval.t @@ -23,7 +23,7 @@ BEGIN { } -plan tests => 519; # Update this when adding/deleting tests. +plan tests => 520; # Update this when adding/deleting tests. run_tests() unless caller; @@ -931,6 +931,11 @@ sub run_tests { like($@, qr/BEGIN failed--compilation aborted at \(eval \d+\) line \d+/, 'syntax error'); + + use utf8; + $code = '(?{Foo::$bar})'; + eval { "a" =~ /^a$code/ }; + like($@, qr/Bad name after Foo:: at \(eval \d+\) line \d+/, 'UTF8 sytax error'); } # make sure that 'use re eval' is propagated into compiling the diff --git a/t/uni/parser.t b/t/uni/parser.t index dcb96f2..b71ca88 100644 --- a/t/uni/parser.t +++ b/t/uni/parser.t @@ -117,9 +117,7 @@ is ${"main::\345\225\217"}, undef, "..and using the encoded form doesn't"; "...and nul-clean" ); - TODO: { - local $::TODO = "Unrecognized character thrown from a re-eval not UTF8/nul clean yet"; - + { use re 'eval'; my $f = qq{(?{\$ネ+ 1; \x{1F42A} })}; eval { "a" =~ /^a$f/ }; -- 2.7.4