Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Decoding utf8 parameters in request

  • Loading branch information...
commit f43e04e99fac9b75106381ab1d8024e94ecc3c78 1 parent b3e12c9
Václav Novák authored

Showing 1 changed file with 12 additions and 0 deletions. Show diff stats Hide diff stats

  1. +12 0 lib/WebNano/Controller.pm
12 lib/WebNano/Controller.pm
@@ -5,6 +5,7 @@ package WebNano::Controller;
5 5
6 6 use URI::Escape 'uri_unescape';
7 7 use Plack::Request;
  8 +use Encode;
8 9
9 10 use WebNano::FindController 'find_nested';
10 11 use Object::Tiny::RW qw/ app env self_url url_map _req path /;
@@ -15,6 +16,8 @@ sub req {
15 16 my $self = shift;
16 17 return $self->_req if defined $self->_req;
17 18 my $req = Plack::Request->new( $self->env );
  19 + _decode_parameters($req->query_parameters);
  20 + _decode_parameters($req->body_parameters);
18 21 $self->_req( $req );
19 22 return $req;
20 23 }
@@ -92,6 +95,15 @@ sub handle {
92 95
93 96 sub search_subcontrollers { 0 }
94 97
  98 +sub _decode_parameters {
  99 + my ($multihash) = @_;
  100 + for my $key (keys %$multihash) {
  101 + my @vals = $multihash->get_all($key);
  102 + $multihash->remove($key);
  103 + $multihash->set(decode_utf8($key), map decode_utf8($_), @vals);
  104 + }
  105 +}
  106 +
95 107 1;
96 108
97 109 __END__

0 comments on commit f43e04e

Please sign in to comment.
Something went wrong with that request. Please try again.