Commit | Line | Data |
4fb27043 |
1 | use strict; |
2 | use warnings; |
3 | use Test::More; |
4 | use utf8; |
5 | |
6 | # setup library path |
7 | use FindBin qw($Bin); |
8 | use lib "$Bin/lib"; |
9 | |
10 | use Catalyst::Test 'TestAppWithoutUnicode'; |
11 | use Encode; |
12 | use HTTP::Request::Common; |
13 | use URI::Escape qw/uri_escape_utf8/; |
14 | use HTTP::Status 'is_server_error'; |
1a87d45c |
15 | use Data::Dumper; |
4fb27043 |
16 | |
17 | my $encode_str = "\x{e3}\x{81}\x{82}"; # e38182 is japanese 'あ' |
18 | my $decode_str = Encode::decode('utf-8' => $encode_str); |
19 | my $escape_str = uri_escape_utf8($decode_str); |
20 | |
b4982899 |
21 | # JNAP - I am removing this test case because I think its not correct. I think |
22 | # we do not check the server encoding to determine if the parts of a request URL |
23 | # both paths and query should be decoded. I think its always safe to assume utf8 |
24 | # encoded urlencoded bits. That is my reading of the spec. Please correct me if |
25 | # I am wrong |
26 | #check_parameter(GET "/?myparam=$escape_str"); |
a6a3355f |
27 | check_parameter(POST '/', |
28 | Content_Type => 'form-data', |
29 | Content => [ |
30 | 'myparam' => [ |
31 | "$Bin/unicode_plugin_no_encoding.t", |
32 | "$Bin/unicode_plugin_request_decode.t", |
33 | ] |
34 | ], |
35 | ); |
4fb27043 |
36 | |
37 | sub check_parameter { |
38 | my ( undef, $c ) = ctx_request(shift); |
4fb27043 |
39 | |
40 | my $myparam = $c->req->param('myparam'); |
a6a3355f |
41 | unless ( $c->request->method eq 'POST' ) { |
42 | is $c->res->output => $encode_str; |
43 | is $myparam => $encode_str; |
44 | } |
4fb27043 |
45 | |
1a87d45c |
46 | is scalar(@TestLogger::ELOGS), 0 |
4fb27043 |
47 | or diag Dumper(\@TestLogger::ELOGS); |
4fb27043 |
48 | } |
49 | |
50 | done_testing; |