summaryrefslogtreecommitdiff
path: root/t/uni
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2012-11-01 12:06:32 -0600
committerKarl Williamson <public@khwilliamson.com>2012-11-11 10:11:34 -0700
commit107160e2175acf35e27ea7b7af0c700f994f5437 (patch)
tree6766127186190810ec6eed356bcc2bbdd9f70c6b /t/uni
parentb6ba113734f2321504b9a5e58f1b107f427927a3 (diff)
downloadperl-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.t9
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{}');
+}