| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Catalyst::Plugin::Unicode; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
922
|
use strict; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
45
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
976
|
use MRO::Compat; |
|
|
1
|
|
|
|
|
3831
|
|
|
|
1
|
|
|
|
|
237
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.93'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub finalize { |
|
10
|
0
|
|
|
0
|
1
|
|
my $c = shift; |
|
11
|
|
|
|
|
|
|
|
|
12
|
0
|
0
|
0
|
|
|
|
if ( $c->response->{body} && utf8::is_utf8($c->response->{body}) ){ |
|
13
|
0
|
|
|
|
|
|
utf8::encode( $c->response->{body} ); |
|
14
|
|
|
|
|
|
|
} |
|
15
|
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
return $c->next::method(@_); |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub prepare_parameters { |
|
20
|
0
|
|
|
0
|
1
|
|
my $c = shift; |
|
21
|
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
$c->next::method(@_); |
|
23
|
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
for my $value ( values %{ $c->request->{parameters} } ) { |
|
|
0
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
0
|
0
|
0
|
|
|
|
if ( ref $value && ref $value ne 'ARRAY' ) { |
|
27
|
0
|
|
|
|
|
|
next; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
|
utf8::decode($_) for ( ref($value) ? @{$value} : $value ); |
|
|
0
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
__END__ |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 NAME |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Catalyst::Plugin::Unicode - Unicode aware Catalyst (old style) |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# DO NOT USE THIS - Use Catalyst::Plugin::Unicode::Encoding instead |
|
45
|
|
|
|
|
|
|
# which is both more correct, and handles more cases. |
|
46
|
|
|
|
|
|
|
use Catalyst qw[Unicode]; |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
On request, decodes all params from UTF-8 octets into a sequence of |
|
51
|
|
|
|
|
|
|
logical characters. On response, encodes body into UTF-8 octets. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Note that this plugin tries to autodetect if your response is encoded into |
|
54
|
|
|
|
|
|
|
characters before trying to encode it into a byte stream. This is B<bad> |
|
55
|
|
|
|
|
|
|
as sometimes it can guess wrongly and cause problems. |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
As an example, latin1 characters such as é (e-accute) will not actually |
|
58
|
|
|
|
|
|
|
cause the output to be encoded as utf8. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Using L<Catalyst::Plugin::Unicode::Encoding> is much more recommended, |
|
61
|
|
|
|
|
|
|
and that also does additional things (like decoding file upload filenames |
|
62
|
|
|
|
|
|
|
and request parameters which this plugin does not). |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
This plugin should be considered deprecated, but is maintained as a large |
|
65
|
|
|
|
|
|
|
number of applications are using it already. |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 OVERLOADED METHODS |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=over 4 |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item finalize |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Encodes body into UTF-8 octets. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item prepare_parameters |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Decodes parameters into a sequence of logical characters. |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=back |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
L<utf8>, L<Catalyst>. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 AUTHORS |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Christian Hansen, C<< <ch@ngmedia.com> >> |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Marcus Ramberg, C<< <mramberg@pcan.org> >> |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Jonathan Rockway C<< <jrockway@cpan.org> >> |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Tomas Doran, (t0m) C<< <bobtfish@bobtfish.net> >> |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Copyright (c) 2005 - 2009 |
|
98
|
|
|
|
|
|
|
the Catalyst::Plugin::Unicode L</AUTHORS> |
|
99
|
|
|
|
|
|
|
as listed above. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 LICENSE |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This library is free software . You can redistribute it and/or modify |
|
104
|
|
|
|
|
|
|
it under the same terms as perl itself. |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=cut |