diff options
author | Karl Williamson <public@khwilliamson.com> | 2012-11-01 12:06:32 -0600 |
---|---|---|
committer | Karl Williamson <public@khwilliamson.com> | 2012-11-11 10:11:34 -0700 |
commit | 107160e2175acf35e27ea7b7af0c700f994f5437 (patch) | |
tree | 6766127186190810ec6eed356bcc2bbdd9f70c6b /t/uni | |
parent | b6ba113734f2321504b9a5e58f1b107f427927a3 (diff) | |
download | perl-107160e2175acf35e27ea7b7af0c700f994f5437.tar.gz |
toke.c: Fail on malformed UTF-8 in \N{} input
The handler for \N{} can be user-supplied and charnames itself
shouldn't have to worry about malformed input. This changes toke.c to
check for malformed input before calling the \N{} handler.
Diffstat (limited to 't/uni')
-rw-r--r-- | t/uni/parser.t | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/t/uni/parser.t b/t/uni/parser.t index 79e4612c65..fb7b720d4c 100644 --- a/t/uni/parser.t +++ b/t/uni/parser.t @@ -7,7 +7,7 @@ BEGIN { require './test.pl'; } -plan (tests => 47); +plan (tests => 48); use utf8; use open qw( :utf8 :std ); @@ -145,3 +145,10 @@ eval q{ Foo::$bar }; like( $@, qr/Bad name after Foo::/, 'Bad name after Foo::' ); eval q{ Foo''bar }; like( $@, qr/Bad name after Foo'/, 'Bad name after Foo\'' ); + +{ + no warnings 'utf8'; + my $malformed_to_be = "\x{c0}\x{a0}"; # Overlong sequence + CORE::evalbytes "use charnames ':full'; use utf8; my \$x = \"\\N{abc$malformed_to_be}\""; + like( $@, qr/Malformed UTF-8 character immediately after '\\N{abc' at .* within string/, 'Malformed UTF-8 input to \N{}'); +} |