Commit | Line | Data |
4fb27043 |
1 | #!/usr/bin/env perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | use Test::More; |
6 | use utf8; |
7 | |
8 | # setup library path |
9 | use FindBin qw($Bin); |
10 | use lib "$Bin/lib"; |
11 | |
12 | use Catalyst::Test 'TestAppWithoutUnicode'; |
13 | use Encode; |
14 | use HTTP::Request::Common; |
15 | use URI::Escape qw/uri_escape_utf8/; |
16 | use HTTP::Status 'is_server_error'; |
1a87d45c |
17 | use Data::Dumper; |
4fb27043 |
18 | |
19 | my $encode_str = "\x{e3}\x{81}\x{82}"; # e38182 is japanese 'あ' |
20 | my $decode_str = Encode::decode('utf-8' => $encode_str); |
21 | my $escape_str = uri_escape_utf8($decode_str); |
22 | |
23 | check_parameter(GET "/?myparam=$escape_str"); |
a6a3355f |
24 | check_parameter(POST '/', |
25 | Content_Type => 'form-data', |
26 | Content => [ |
27 | 'myparam' => [ |
28 | "$Bin/unicode_plugin_no_encoding.t", |
29 | "$Bin/unicode_plugin_request_decode.t", |
30 | ] |
31 | ], |
32 | ); |
4fb27043 |
33 | |
34 | sub check_parameter { |
35 | my ( undef, $c ) = ctx_request(shift); |
4fb27043 |
36 | |
37 | my $myparam = $c->req->param('myparam'); |
38 | ok !utf8::is_utf8($myparam); |
a6a3355f |
39 | unless ( $c->request->method eq 'POST' ) { |
40 | is $c->res->output => $encode_str; |
41 | is $myparam => $encode_str; |
42 | } |
4fb27043 |
43 | |
1a87d45c |
44 | is scalar(@TestLogger::ELOGS), 0 |
4fb27043 |
45 | or diag Dumper(\@TestLogger::ELOGS); |
4fb27043 |
46 | } |
47 | |
48 | done_testing; |