aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/CGI.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-05-21 15:30:56 -0400
committerJoey Hess <joey@kodama.kitenet.net>2008-05-21 15:30:56 -0400
commitf6f25758a83c20d4fd17aed7602d8828c59903b7 (patch)
treeeab451a25d6bef0d32f3fcfd945cf5733e3c17ab /IkiWiki/CGI.pm
parent9a8a67f078117129ee2fcedd3c704391bdc2723c (diff)
downloadikiwiki-f6f25758a83c20d4fd17aed7602d8828c59903b7.tar
ikiwiki-f6f25758a83c20d4fd17aed7602d8828c59903b7.tar.gz
Perls older than 5.10 need to use the old method of decoding utf-8 in CGI values. Neither method will work for all versions of perl, so check version number at runtime.
Diffstat (limited to 'IkiWiki/CGI.pm')
-rw-r--r--IkiWiki/CGI.pm28
1 files changed, 22 insertions, 6 deletions
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm
index 1ec0128fe..532f9c5f6 100644
--- a/IkiWiki/CGI.pm
+++ b/IkiWiki/CGI.pm
@@ -77,13 +77,25 @@ sub check_canedit ($$$;$) { #{{{
return $canedit;
} #}}}
+sub decode_cgi_utf8 ($) { #{{{
+ # decode_form_utf8 method is needed for 5.10
+ if ($] < 5.01) {
+ my $cgi = shift;
+ foreach my $f ($cgi->param) {
+ $cgi->param($f, map { decode_utf8 $_ } $cgi->param($f));
+ }
+ }
+} #}}}
+
sub decode_form_utf8 ($) { #{{{
- my $form = shift;
- foreach my $f ($form->field) {
- $form->field(name => $f,
- value => decode_utf8($form->field($f)),
- force => 1,
- );
+ if ($] >= 5.01) {
+ my $form = shift;
+ foreach my $f ($form->field) {
+ $form->field(name => $f,
+ value => decode_utf8($form->field($f)),
+ force => 1,
+ );
+ }
}
} #}}}
@@ -106,6 +118,7 @@ sub cgi_signin ($$) { #{{{
my $q=shift;
my $session=shift;
+ decode_cgi_utf8($q);
eval q{use CGI::FormBuilder};
error($@) if $@;
my $form = CGI::FormBuilder->new(
@@ -165,6 +178,7 @@ sub cgi_prefs ($$) { #{{{
my $session=shift;
needsignin($q, $session);
+ decode_cgi_utf8($q);
# The session id is stored on the form and checked to
# guard against CSRF.
@@ -260,6 +274,8 @@ sub cgi_editpage ($$) { #{{{
my $q=shift;
my $session=shift;
+ decode_cgi_utf8($q);
+
my @fields=qw(do rcsinfo subpage from page type editcontent comments);
my @buttons=("Save Page", "Preview", "Cancel");
eval q{use CGI::FormBuilder};