X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/d552b2843020283b019729caf588f2e60b3a5396..91cb55d96b549e3b29afb398a79d15591e39e3aa:/IkiWiki.pm diff --git a/IkiWiki.pm b/IkiWiki.pm index 1aaa4d33c..2ad2f792d 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -277,13 +277,20 @@ sub getsetup () { #{{{ }, umask => { type => "integer", - description => "", example => "022", description => "force ikiwiki to use a particular umask", advanced => 1, safe => 0, # paranoia rebuild => 0, }, + wrappergroup => { + type => "string", + example => "ikiwiki", + description => "group for wrappers to run in", + advanced => 1, + safe => 0, # paranoia + rebuild => 0, + }, libdir => { type => "string", default => "", @@ -721,6 +728,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; } #}}} @@ -938,9 +949,9 @@ sub beautify_urlpath ($) { #{{{ $url =~ s!/index.$config{htmlext}$!/!; } - # Ensure url is not an empty link, and - # if it's relative, make that explicit to avoid colon confusion. - if ($url !~ /^\//) { + # Ensure url is not an empty link, and if necessary, + # add ./ to avoid colon confusion. + if ($url !~ /^\// && $url !~ /^\.\.\//) { $url="./$url"; } @@ -1280,8 +1291,7 @@ sub indexlink () { #{{{ my $wikilock; -sub lockwiki (;$) { #{{{ - my $wait=@_ ? shift : 1; +sub lockwiki () { #{{{ # Take an exclusive lock on the wiki to prevent multiple concurrent # run issues. The lock will be dropped on program exit. if (! -d $config{wikistatedir}) { @@ -1289,25 +1299,14 @@ sub lockwiki (;$) { #{{{ } open($wikilock, '>', "$config{wikistatedir}/lockfile") || error ("cannot write to $config{wikistatedir}/lockfile: $!"); - if (! flock($wikilock, 2 | 4)) { # LOCK_EX | LOCK_NB - if ($wait) { - debug("wiki seems to be locked, waiting for lock"); - my $wait=600; # arbitrary, but don't hang forever to - # prevent process pileup - for (1..$wait) { - return if flock($wikilock, 2 | 4); - sleep 1; - } - error("wiki is locked; waited $wait seconds without lock being freed (possible stuck process or stale lock?)"); - } - else { - return 0; - } + if (! flock($wikilock, 2)) { # LOCK_EX + error("failed to get lock"); } return 1; } #}}} sub unlockwiki () { #{{{ + POSIX::close($ENV{IKIWIKI_CGILOCK_FD}) if exists $ENV{IKIWIKI_CGILOCK_FD}; return close($wikilock) if $wikilock; return; } #}}} @@ -1901,6 +1900,10 @@ sub match_link ($$;@) { #{{{ else { return IkiWiki::SuccessReason->new("$page links to page $p matching $link") if match_glob($p, $link, %params); + $p=~s/^\///; + $link=~s/^\///; + return IkiWiki::SuccessReason->new("$page links to page $p matching $link") + if match_glob($p, $link, %params); } } return IkiWiki::FailReason->new("$page does not link to $link");