Created
March 18, 2014 09:36
-
-
Save hisaichi5518/9616700 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Plack/Request/WithEncoding.pm b/lib/Plack/Request/WithEncoding.pm | |
index 45d3d3f..aa8f36b 100644 | |
--- a/lib/Plack/Request/WithEncoding.pm | |
+++ b/lib/Plack/Request/WithEncoding.pm | |
@@ -81,11 +81,34 @@ sub _decode_parameters { | |
my @flatten = $stuff->flatten; | |
my @decoded; | |
while ( my ($k, $v) = splice @flatten, 0, 2 ) { | |
- push @decoded, $encoding->decode($k), $encoding->decode($v); | |
+ push @decoded, $self->__decode($encoding, $k), $self->__decode($encoding, $v); | |
} | |
return Hash::MultiValue->new(@decoded); | |
} | |
_ | |
+sub __decode { | |
+ my ($self, $encoding, $data) = @_; | |
+ | |
+ if (ref $data eq "ARRAY") { | |
+ my @result; | |
+ for my $d (@$data) { | |
+ push @result, $self->__decode($encoding, $d); | |
+ } | |
+ | |
+ return \@result; | |
+ } | |
+ elsif (ref $data eq "HASH") { | |
+ my %result; | |
+ while (my ($k, $v) = each %$data) { | |
+ $result{$self->__decode($encoding, $k)} = $self->__decode($encoding, $v); | |
+ } | |
+ | |
+ return \%result; | |
+ } | |
+ | |
+ return $encoding->decode($data); | |
+} | |
+ | |
1; | |
__END__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment