expand ParamParser comment so nobody breaks it again
[catagits/Web-Simple.git] / lib / Web / Dispatch / ParamParser.pm
index e8ed581..3caf160 100644 (file)
@@ -3,6 +3,8 @@ package Web::Dispatch::ParamParser;
 use strict;
 use warnings FATAL => 'all';
 
+use Encode 'decode_utf8';
+
 sub UNPACKED_QUERY () { __PACKAGE__.'.unpacked_query' }
 sub UNPACKED_BODY () { __PACKAGE__.'.unpacked_body' }
 sub UNPACKED_BODY_OBJECT () { __PACKAGE__.'.unpacked_body_object' }
@@ -25,7 +27,8 @@ sub get_unpacked_body_from {
       _unpack_params($buf);
     } elsif (index($ct, 'multipart/form-data') >= 0) {
       my $p = get_unpacked_body_object_from($_[0])->param;
-      # forcible arrayification
+      # forcible arrayification (functional, $p does not belong to us,
+      # do NOT replace this with a side-effect ridden "simpler" version)
       +{
         map +(ref($p->{$_}) eq 'ARRAY'
                ? ($_ => $p->{$_})
@@ -102,8 +105,9 @@ sub get_unpacked_uploads_from {
     my ($name, $value);
     foreach my $pair (split(/[&;](?:\s+)?/, $params)) {
       next unless (($name, $value) = split(/=/, $pair, 2)) == 2;
-        
+
       s/$DECODE/$hex_chr{$1}/gs for ($name, $value);
+      $_ = decode_utf8 $_ for ($name, $value);
 
       push(@{$unpack{$name}||=[]}, $value);
     }