sub import {
hook(type => "cgi", id => 'goto', call => \&cgi);
+ hook(type => "getsetup", id => 'goto', call => \&getsetup);
}
sub getsetup () {
my $page = shift;
if (!defined $page) {
- $page = IkiWiki::decode_utf8($q->param("page"));
+ $page = IkiWiki::decode_utf8(scalar $q->param("page"));
if (!defined $page) {
error("missing page parameter");
IkiWiki::redirect($q, $pagestate{$page}{meta}{permalink});
}
- if (! length $link) {
+ if (! defined $link || ! length $link) {
IkiWiki::cgi_custom_failure(
$q,
"404 Not Found",
- IkiWiki::misctemplate(gettext("missing page"),
+ IkiWiki::cgitemplate($q, gettext("missing page"),
"<p>".
sprintf(gettext("The page %s does not exist."),
htmllink("", "", $page)).
)
}
else {
- IkiWiki::redirect($q, urlto($link, undef, 1));
+ IkiWiki::redirect($q, urlto($link));
}
exit;