use PerlIO::utf8_strict for decoding uploads
Graham Knop [Sun, 21 Oct 2018 09:11:27 +0000 (11:11 +0200)]
PerlIO::utf8_strict is faster than the encoding layer.

Makefile.PL
lib/Catalyst/Request/Upload.pm

index 3397a3d..8289765 100644 (file)
@@ -78,6 +78,7 @@ my %META = (
         "Plack::Middleware::FixMissingBodyInRedirect" => '0.09',
         "Plack::Middleware::MethodOverride" => '0.12',
         "Plack::Middleware::RemoveRedundantBody" => '0.03',
+        'PerlIO::utf8_strict' => 0,
       },
     },
     develop   => {
index 486653c..e4c35ed 100644 (file)
@@ -7,6 +7,7 @@ use Catalyst::Exception;
 use File::Copy ();
 use IO::File ();
 use File::Spec::Unix;
+use PerlIO::utf8_strict;
 use namespace::clean -except => 'meta';
 
 has filename => (is => 'rw');
@@ -157,7 +158,7 @@ sub decoded_fh {
     my ($self, $layer) = @_;
     my $fh  = $self->fh;
 
-    $layer = ":encoding(UTF-8)" if !$layer && $self->is_utf8_encoded;
+    $layer = ':utf8_strict' if !$layer && $self->is_utf8_encoded;
     $layer = ':raw' unless $layer;
 
     binmode($fh, $layer);