]> sipb.mit.edu Git - ikiwiki.git/blobdiff - ikiwiki
web commit by WillThompson: Safety of arbitrary regexen
[ikiwiki.git] / ikiwiki
diff --git a/ikiwiki b/ikiwiki
index 4ef6ceba39d3e7cb07dd32ea27dc27bade27bdf4..f7ccaf743ea0420a061a67a5944ea463d2ddfc43 100755 (executable)
--- a/ikiwiki
+++ b/ikiwiki
@@ -36,6 +36,7 @@ sub getconfig () { #{{{
                        rebuild => 0,
                        refresh => 0,
                        getctime => 0,
+                       hyperestraier => 0,
                        wrapper => undef,
                        wrappermode => undef,
                        srcdir => undef,
@@ -57,6 +58,7 @@ sub getconfig () { #{{{
                        "wrappermode=i" => \$config{wrappermode},
                        "svn!" => \$config{svn},
                        "anonok!" => \$config{anonok},
+                       "hyperestraier" => \$config{hyperestraier},
                        "rss!" => \$config{rss},
                        "cgi!" => \$config{cgi},
                        "url=s" => \$config{url},
@@ -102,6 +104,9 @@ sub checkconfig () { #{{{
        if ($config{rss} && ! length $config{url}) {
                error("Must specify url to wiki with --url when using --rss\n");
        }
+       if ($config{hyperestraier} && ! length $config{url}) {
+               error("Must specify --url when using --hyperestraier\n");
+       }
        
        $config{wikistatedir}="$config{srcdir}/.ikiwiki"
                unless exists $config{wikistatedir};
@@ -202,15 +207,20 @@ sub readfile ($) { #{{{
        return $ret;
 } #}}}
 
-sub writefile ($$) { #{{{
-       my $file=shift;
+sub writefile ($$$) { #{{{
+       my $file=shift; # can include subdirs
+       my $destdir=shift; # directory to put file in
        my $content=shift;
        
-       if (-l $file) {
-               error("cannot write to a symlink ($file)");
+       my $test=$file;
+       while (length $test) {
+               if (-l "$destdir/$test") {
+                       error("cannot write to a symlink ($test)");
+               }
+               $test=dirname($test);
        }
 
-       my $dir=dirname($file);
+       my $dir=dirname("$destdir/$file");
        if (! -d $dir) {
                my $d="";
                foreach my $s (split(m!/+!, $dir)) {
@@ -221,7 +231,7 @@ sub writefile ($$) { #{{{
                }
        }
        
-       open (OUT, ">$file") || error("failed to write $file: $!");
+       open (OUT, ">$destdir/$file") || error("failed to write $destdir/$file: $!");
        print OUT $content;
        close OUT;
 } #}}}
@@ -418,6 +428,7 @@ sub misctemplate ($$) { #{{{
                wikiname => $config{wikiname},
                pagebody => $pagebody,
                styleurl => styleurl(),
+               baseurl => "$config{url}/",
        );
        return $template->output;
 }#}}}