]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki.pm
ikiwiki-mass-rebuild: Fix tty hijacking vulnerability by using su. (Once su's related...
[git.ikiwiki.info.git] / IkiWiki.pm
index 4de8f71d6ce60743de22d0ea9efaeeb875de5999..443c7044796a29947936fd5de57e8e09c14bfec4 100644 (file)
@@ -151,7 +151,9 @@ sub loadplugins () { #{{{
                unshift @INC, possibly_foolish_untaint($config{libdir});
        }
 
-       loadplugin($_) foreach @{$config{plugin}};
+       foreach my $plugin (@{$config{plugin}}) {
+               loadplugin($plugin);
+       }
 
        run_hooks(getopt => sub { shift->() });
        if (grep /^-/, @ARGV) {
@@ -332,6 +334,10 @@ sub readfile ($;$$) { #{{{
        binmode($in) if ($binary);
        return \*$in if $wantfd;
        my $ret=<$in>;
+       # check for invalid utf-8, and toss it back to avoid crashes
+       if (! utf8::valid($ret)) {
+               $ret=encode_utf8($ret);
+       }
        close $in || error("failed to read $file: $!");
        return $ret;
 } #}}}
@@ -541,17 +547,18 @@ sub beautify_url ($) { #{{{
 
        # Ensure url is not an empty link, and
        # if it's relative, make that explicit to avoid colon confusion.
-       if ($url !~ /\//) {
+       if ($url !~ /^\//) {
                $url="./$url";
        }
 
        return $url;
 } #}}}
 
-sub urlto ($$) { #{{{
+sub urlto ($$;$) { #{{{
        my $to=shift;
        my $from=shift;
-
+       my $absolute=shift;
+       
        if (! length $to) {
                return beautify_url(baseurl($from)."index.$config{htmlext}");
        }
@@ -560,6 +567,10 @@ sub urlto ($$) { #{{{
                $to=htmlpage($to);
        }
 
+       if ($absolute) {
+               return $config{url}.beautify_url("/".$to);
+       }
+
        my $link = abs2rel($to, dirname(htmlpage($from)));
 
        return beautify_url($link);
@@ -720,7 +731,7 @@ sub preprocess ($$$;$$) { #{{{
                my $params=shift;
                $params="" if ! defined $params;
 
-               f (length $escape) {
+               if (length $escape) {
                        return "[[$prefix$command $params]]";
                }
                elsif (exists $hooks{preprocess}{$command}) {