diff options
author | Hugo van der Sanden <hv@crypt.org> | 2015-02-07 16:31:04 +0000 |
---|---|---|
committer | Hugo van der Sanden <hv@crypt.org> | 2015-02-09 18:49:56 +0000 |
commit | 8a6d8ec6fe627c401c6c759edd38bbb10e4b56e9 (patch) | |
tree | a2fa79d6a2b22a188c5ff54717374e13ebf4d3c6 /t/re | |
parent | a53bfdae91fb2d719e69761f2d2f84c5d8a47753 (diff) | |
download | perl-8a6d8ec6fe627c401c6c759edd38bbb10e4b56e9.tar.gz |
[perl #123755] including unknown char in error requires care
AFL (<http://lcamtuf.coredump.cx/afl>) found that when producing the
error message for /(??/ we hit an assert because we've stepped past
the end of the pattern string. Code inspection found that we also do
that in other branches, and we also need to check UTF more carefully.
Diffstat (limited to 't/re')
-rw-r--r-- | t/re/pat.t | 13 | ||||
-rw-r--r-- | t/re/re_tests | 2 |
2 files changed, 13 insertions, 2 deletions
diff --git a/t/re/pat.t b/t/re/pat.t index 3d52554754..53972fea9d 100644 --- a/t/re/pat.t +++ b/t/re/pat.t @@ -22,7 +22,7 @@ BEGIN { skip_all_without_unicode_tables(); } -plan tests => 759; # Update this when adding/deleting tests. +plan tests => 765; # Update this when adding/deleting tests. run_tests() unless caller; @@ -1635,6 +1635,17 @@ EOP ok(1, "did not crash"); ok($match, "[bbb...] resolved as character class, not subscript"); } + + { # [perl #123755] + for my $pat ('(??', '(?P', '(?i-') { + eval qq{ qr/$pat/ }; + ok(1, "qr/$pat/ did not crash"); + eval qq{ qr/${pat}\x{123}/ }; + my $e = $@; + like($e, qr{\x{123}}, + "qr/${pat}x/ shows x in error even if it's a wide character"); + } + } } # End of sub run_tests 1; diff --git a/t/re/re_tests b/t/re/re_tests index ce8d0cfb6b..41cda56433 100644 --- a/t/re/re_tests +++ b/t/re/re_tests @@ -1102,7 +1102,7 @@ X(?<=foo.)[YZ] ..XfooXY.. y pos 8 (?P<n>foo)(??{ $+{n} }) snofooefoofoowaa yM $+{n} foo miniperl cannot load Tie::Hash::NamedCapture (?P<=n>foo|bar|baz) - c - Group name must start with a non-digit word character (?P<!n>foo|bar|baz) - c - Group name must start with a non-digit word character -(?PX<n>foo|bar|baz) - c - Sequence (?PX<...) not recognized +(?PX<n>foo|bar|baz) - c - Sequence (?PX...) not recognized /(?'n'foo|bar|baz)/ snofooewa y $1 foo /(?'n'foo|bar|baz)/ snofooewa yM $+{n} foo miniperl cannot load Tie::Hash::NamedCapture /(?'n'foo|bar|baz)(?'m'[ew]+)/ snofooewa yM $+{n} foo miniperl cannot load Tie::Hash::NamedCapture |