do not double-decode unicode in CGI forms
this works around a behavior change introduced in Encode.pm 2.53 shipped with the Perl 5.20 release described here: http://ikiwiki.info/bugs/garbled_non-ascii_characters_in_body_in_web_interface/master
parent
6057107d71
commit
feb21ebfac
|
@ -110,11 +110,23 @@ sub decode_cgi_utf8 ($) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub safe_decode_utf8 ($) {
|
||||||
|
my $octets = shift;
|
||||||
|
# call decode_utf8 on >= 5.20 only if it's not already decoded,
|
||||||
|
# otherwise it balks, on < 5.20, always call it
|
||||||
|
if ($] < 5.02 || !Encode::is_utf8($octets)) {
|
||||||
|
return decode_utf8($octets);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return $octets;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub decode_form_utf8 ($) {
|
sub decode_form_utf8 ($) {
|
||||||
if ($] >= 5.01) {
|
if ($] >= 5.01) {
|
||||||
my $form = shift;
|
my $form = shift;
|
||||||
foreach my $f ($form->field) {
|
foreach my $f ($form->field) {
|
||||||
my @value=map { decode_utf8($_) } $form->field($f);
|
my @value=map { safe_decode_utf8($_) } $form->field($f);
|
||||||
$form->field(name => $f,
|
$form->field(name => $f,
|
||||||
value => \@value,
|
value => \@value,
|
||||||
force => 1,
|
force => 1,
|
||||||
|
|
Loading…
Reference in New Issue