X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/d1b22b252481134815b1d02d564b6b9622fe7b4b..0e31e924e88d660b75bb8d33fb6ca1eb80a8a5e2:/IkiWiki.pm diff --git a/IkiWiki.pm b/IkiWiki.pm index d949566d8..735dc97b1 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -721,6 +721,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; } #}}} @@ -1295,6 +1299,7 @@ sub lockwiki () { #{{{ } #}}} sub unlockwiki () { #{{{ + POSIX::close($ENV{IKIWIKI_CGILOCK_FD}) if exists $ENV{IKIWIKI_CGILOCK_FD}; return close($wikilock) if $wikilock; return; } #}}}