On some systems the commit message gets quoted properly already. Don't
authorAmitai Schlair <schmonz@magnetic-babysitter.(none)>
Sun, 30 Aug 2009 20:13:17 +0000 (16:13 -0400)
committerAmitai Schlair <schmonz@magnetic-babysitter.(none)>
Sun, 30 Aug 2009 20:13:17 +0000 (16:13 -0400)
requote in such cases, do quote in all others.

IkiWiki/Plugin/cvs.pm

index fa4c4da8e94ad250e0615786fe57b508fb2bbfcd..849302df46c80333a1e0d1863d6a8a2dffc33c32 100644 (file)
@@ -119,11 +119,21 @@ sub cvs_runcvs(@) {
 
 sub cvs_shquote_commit ($) {
        my $message = shift;
+       my $test_message = "CVS autodiscover quoting CVS";
 
        eval q{use String::ShellQuote};
        error($@) if $@;
+       eval q{use IPC::Cmd};
+       error($@) if $@;
 
-       return shell_quote(IkiWiki::possibly_foolish_untaint($message));
+       my $cmd = ['echo', shell_quote($test_message)];
+       my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) =
+               IPC::Cmd::run(command => $cmd, verbose => 0);
+       if ((grep /'$test_message'/, @$stdout_buf) > 0) {
+               return IkiWiki::possibly_foolish_untaint($message);
+       } else {
+               return shell_quote(IkiWiki::possibly_foolish_untaint($message));
+       }
 }
 
 sub cvs_is_controlling {