X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/99fce0af0d4e99bc81ef7847bfbe77662763e805..58e346d229557915b3f8b70c8f63ae4184e50e27:/IkiWiki.pm diff --git a/IkiWiki.pm b/IkiWiki.pm index 684713821..68047b9b9 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -87,6 +87,7 @@ sub defaultconfig () { #{{{ numbacklinks => 10, account_creation_password => "", prefix_directives => 0, + hardlink => 0, } #}}} sub checkconfig () { #{{{ @@ -323,12 +324,9 @@ sub readfile ($;$$) { #{{{ return $ret; } #}}} -sub writefile ($$$;$$) { #{{{ - my $file=shift; # can include subdirs - my $destdir=shift; # directory to put file in - my $content=shift; - my $binary=shift; - my $writer=shift; +sub prep_writefile ($$) { + my $file=shift; + my $destdir=shift; my $test=$file; while (length $test) { @@ -337,12 +335,8 @@ sub writefile ($$$;$$) { #{{{ } $test=dirname($test); } - my $newfile="$destdir/$file.ikiwiki-new"; - if (-l $newfile) { - error("cannot write to a symlink ($newfile)"); - } - my $dir=dirname($newfile); + my $dir=dirname("$destdir/$file"); if (! -d $dir) { my $d=""; foreach my $s (split(m!/+!, $dir)) { @@ -353,6 +347,23 @@ sub writefile ($$$;$$) { #{{{ } } + return 1; +} + +sub writefile ($$$;$$) { #{{{ + my $file=shift; # can include subdirs + my $destdir=shift; # directory to put file in + my $content=shift; + my $binary=shift; + my $writer=shift; + + prep_writefile($file, $destdir); + + my $newfile="$destdir/$file.ikiwiki-new"; + if (-l $newfile) { + error("cannot write to a symlink ($newfile)"); + } + my $cleanup = sub { unlink($newfile) }; open (my $out, '>', $newfile) || error("failed to write $newfile: $!", $cleanup); binmode($out) if ($binary); @@ -610,6 +621,9 @@ sub userlink ($) { #{{{ return "$oiduser"; } else { + eval q{use CGI 'escapeHTML'}; + error($@) if $@; + return htmllink("", "", escapeHTML( length $config{userdir} ? $config{userdir}."/".$user : $user ), noimageinline => 1);