]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/recentchanges.pm
decode utf-8 in recentchanges_link parameter
[ikiwiki.git] / IkiWiki / Plugin / recentchanges.pm
index 8383fb72a12e19c8d92627956efc154855ff57e5..563ab7db1950e1d9ca4863d54784a86ca2bd47ea 100644 (file)
@@ -4,8 +4,10 @@ package IkiWiki::Plugin::recentchanges;
 use warnings;
 use strict;
 use IkiWiki 2.00;
+use Encode;
 
 sub import { #{{{
+       hook(type => "getsetup", id => "recentchanges", call => \&getsetup);
        hook(type => "checkconfig", id => "recentchanges", call => \&checkconfig);
        hook(type => "refresh", id => "recentchanges", call => \&refresh);
        hook(type => "pagetemplate", id => "recentchanges", call => \&pagetemplate);
@@ -13,6 +15,28 @@ sub import { #{{{
        hook(type => "cgi", id => "recentchanges", call => \&cgi);
 } #}}}
 
+sub getsetup () { #{{{
+       return
+               plugin => {
+                       safe => 1,
+                       rebuild => 1,
+               },
+               recentchangespage => {
+                       type => "string",
+                       example => "recentchanges",
+                       description => "name of the recentchanges page",
+                       safe => 1,
+                       rebuild => 1,
+               },
+               recentchangesnum => {
+                       type => "integer",
+                       example => 100,
+                       description => "number of changes to track",
+                       safe => 1,
+                       rebuild => 0,
+               },
+} #}}}
+
 sub checkconfig () { #{{{
        $config{recentchangespage}='recentchanges' unless defined $config{recentchangespage};
        $config{recentchangesnum}=100 unless defined $config{recentchangesnum};
@@ -63,7 +87,7 @@ sub cgi ($) { #{{{
                # page they link to is deleted, or newly created, or
                # changes for whatever reason. So this CGI handles that
                # dynamic linking stuff.
-               my $page=$cgi->param("page");
+               my $page=decode_utf8($cgi->param("page"));
                if (!defined $page) {
                        error("missing page parameter");
                }
@@ -80,7 +104,12 @@ sub cgi ($) { #{{{
                                "</p>");
                }
                else {
-                       IkiWiki::redirect($cgi, $config{url}.IkiWiki::beautify_urlpath("/".htmlpage($link)));
+                       if (defined pagetype($link)) {
+                               IkiWiki::redirect($cgi, $config{url}.IkiWiki::beautify_urlpath("/".htmlpage($link)));
+                       }
+                       else {
+                               IkiWiki::redirect($cgi, $config{url}.IkiWiki::beautify_urlpath("/".$link));
+                       }
                }
 
                exit;