X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/985b229be632126f376aaad7bd354d0d7d014464..05bb65fc687b357a5265f0c378a694b5b02d376d:/IkiWiki/CGI.pm?ds=sidebyside diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index a45e12e31..81cb42d13 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -9,7 +9,7 @@ use IkiWiki::UserInfo; use open qw{:utf8 :std}; use Encode; -sub printheader ($) { #{{{ +sub printheader ($) { my $session=shift; if ($config{sslcookie}) { @@ -19,9 +19,9 @@ sub printheader ($) { #{{{ print $session->header(-charset => 'utf-8', -cookie => $session->cookie(-httponly => 1)); } -} #}}} +} -sub showform ($$$$;@) { #{{{ +sub showform ($$$$;@) { my $form=shift; my $buttons=shift; my $session=shift; @@ -36,9 +36,9 @@ sub showform ($$$$;@) { #{{{ printheader($session); print misctemplate($form->title, $form->render(submit => $buttons), @_); -} #}}} +} -sub redirect ($$) { #{{{ +sub redirect ($$) { my $q=shift; my $url=shift; if (! $config{w3mmode}) { @@ -48,9 +48,9 @@ sub redirect ($$) { #{{{ print "Content-type: text/plain\n"; print "W3m-control: GOTO $url\n\n"; } -} #}}} +} -sub decode_cgi_utf8 ($) { #{{{ +sub decode_cgi_utf8 ($) { # decode_form_utf8 method is needed for 5.10 if ($] < 5.01) { my $cgi = shift; @@ -58,9 +58,9 @@ sub decode_cgi_utf8 ($) { #{{{ $cgi->param($f, map { decode_utf8 $_ } $cgi->param($f)); } } -} #}}} +} -sub decode_form_utf8 ($) { #{{{ +sub decode_form_utf8 ($) { if ($] >= 5.01) { my $form = shift; foreach my $f ($form->field) { @@ -70,11 +70,11 @@ sub decode_form_utf8 ($) { #{{{ ); } } -} #}}} +} # Check if the user is signed in. If not, redirect to the signin form and # save their place to return to later. -sub needsignin ($$) { #{{{ +sub needsignin ($$) { my $q=shift; my $session=shift; @@ -85,9 +85,9 @@ sub needsignin ($$) { #{{{ cgi_savesession($session); exit; } -} #}}} +} -sub cgi_signin ($$) { #{{{ +sub cgi_signin ($$) { my $q=shift; my $session=shift; @@ -127,9 +127,9 @@ sub cgi_signin ($$) { #{{{ } showform($form, $buttons, $session, $q); -} #}}} +} -sub cgi_postsignin ($$) { #{{{ +sub cgi_postsignin ($$) { my $q=shift; my $session=shift; @@ -144,9 +144,9 @@ sub cgi_postsignin ($$) { #{{{ else { error(gettext("login failed, perhaps you need to turn on cookies?")); } -} #}}} +} -sub cgi_prefs ($$) { #{{{ +sub cgi_prefs ($$) { my $q=shift; my $session=shift; @@ -254,9 +254,9 @@ sub cgi_prefs ($$) { #{{{ } showform($form, $buttons, $session, $q); -} #}}} +} -sub check_banned ($$) { #{{{ +sub check_banned ($$) { my $q=shift; my $session=shift; @@ -273,9 +273,9 @@ sub check_banned ($$) { #{{{ exit; } } -} #}}} +} -sub cgi_getsession ($) { #{{{ +sub cgi_getsession ($) { my $q=shift; eval q{use CGI::Session; use HTML::Entities}; @@ -294,13 +294,13 @@ sub cgi_getsession ($) { #{{{ umask($oldmask); return $session; -} #}}} +} # To guard against CSRF, the user's session id (sid) # can be stored on a form. This function will check # (for logged in users) that the sid on the form matches # the session id in the cookie. -sub checksessionexpiry ($$) { # {{{ +sub checksessionexpiry ($$) { my $q=shift; my $session = shift; @@ -310,18 +310,18 @@ sub checksessionexpiry ($$) { # {{{ error(gettext("Your login session has expired.")); } } -} # }}} +} -sub cgi_savesession ($) { #{{{ +sub cgi_savesession ($) { my $session=shift; # Force session flush with safe umask. my $oldmask=umask(077); $session->flush; umask($oldmask); -} #}}} +} -sub cgi (;$$) { #{{{ +sub cgi (;$$) { my $q=shift; my $session=shift; @@ -391,16 +391,16 @@ sub cgi (;$$) { #{{{ else { error("unknown do parameter"); } -} #}}} +} # Does not need to be called directly; all errors will go through here. -sub cgierror ($) { #{{{ +sub cgierror ($) { my $message=shift; print "Content-type: text/html\n\n"; print misctemplate(gettext("Error"), "
".gettext("Error").": $message
"); die $@; -} #}}} +} 1