X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/64aca7c30b5ffc48546bdd7f3001b0a0b4bae072..2e15a490067991448c3b65323ad9ecdc774dbfe4:/IkiWiki/Plugin/cvs.pm diff --git a/IkiWiki/Plugin/cvs.pm b/IkiWiki/Plugin/cvs.pm index 42812ddef..f6f7edfb2 100644 --- a/IkiWiki/Plugin/cvs.pm +++ b/IkiWiki/Plugin/cvs.pm @@ -1,11 +1,11 @@ #!/usr/bin/perl package IkiWiki::Plugin::cvs; -# Copyright (c) 2009 Amitai Schlair +# Copyright (c) 2009 Amitai Schleier # All rights reserved. # # This code is derived from software contributed to ikiwiki -# by Amitai Schlair. +# by Amitai Schleier. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -33,6 +33,7 @@ use warnings; use strict; use IkiWiki; +use URI::Escape q{uri_escape_utf8}; use File::chdir; @@ -313,7 +314,10 @@ sub rcs_recentchanges ($) { $oldrev =~ s/INITIAL/0/; $newrev =~ s/\(DEAD\)//; my $diffurl = defined $config{diffurl} ? $config{diffurl} : ""; - $diffurl=~s/\[\[file\]\]/$page/g; + my $epage = join('/', + map { uri_escape_utf8($_) } split('/', $page) + ); + $diffurl=~s/\[\[file\]\]/$epage/g; $diffurl=~s/\[\[r1\]\]/$oldrev/g; $diffurl=~s/\[\[r2\]\]/$newrev/g; unshift @pages, { @@ -452,12 +456,12 @@ sub commitmessage (@) { if (defined $params{session}) { if (defined $params{session}->param("name")) { return "web commit by ". - $params{session}->param("name"). + IkiWiki::cloak($params{session}->param("name")). (length $params{message} ? ": $params{message}" : ""); } elsif (defined $params{session}->remote_addr()) { return "web commit from ". - $params{session}->remote_addr(). + IkiWiki::cloak($params{session}->remote_addr()). (length $params{message} ? ": $params{message}" : ""); } } @@ -500,7 +504,16 @@ sub cvs_runcvs(@) { my @cmd = @_; unshift @cmd, 'cvs', '-Q'; - local $CWD = $config{srcdir}; + # CVS can't operate outside a srcdir, so we're always setting $CWD. + # "local $CWD" restores the previous value when we go out of scope. + # Usually that's correct. But if we're removing the last file from + # a directory, the post-commit hook will exec in a working directory + # that's about to not exist (CVS will prune it). + # + # chdir() manually here, so we can selectively not chdir() back. + + my $oldcwd = $CWD; + chdir($config{srcdir}); eval q{ use IPC::Open3; @@ -528,6 +541,8 @@ sub cvs_runcvs(@) { print STDOUT $cvsout; print STDERR $cvserr; + chdir($oldcwd) if -d $oldcwd; + return ($ret == 0) ? 1 : 0; }