]> git.donarmstrong.com Git - bin.git/blobdiff - sshsendmail
fix broken nullmailer quote handling
[bin.git] / sshsendmail
index 081f0e3caa39cdb1a1d099d7034d6a7cf8d1b71f..047d9a869ae1385691ced590857d1cea71c70d26 100755 (executable)
@@ -82,6 +82,27 @@ my %options = (debug              => 0,
               'sendmail-options' => '',
              );
 
+# this is really janky, but because nullmailer doesn't properly handle
+# quotes, we must do it for it.
+my @fixed_argv;
+my $concatenate_to_last;
+my $p;
+for my $opt (@ARGV) {
+    if ($concatenate_to_last) {
+        $fixed_argv[-1].=' '.$opt;
+        if (/$p/) {
+            $concatenate_to_last = 0;
+        }
+        next;
+    }
+    if (/(['"])(.+)/ && $2 !~ /$1/) {
+        $p = $1;
+        $concatenate_to_last = 1;
+    }
+    push @fixed_argv,$opt;
+}
+@ARGV=@fixed_argv;
+
 GetOptions(\%options,'identity|i=s','username|l=s','daemon|d', 'syslog|s',
           'sendmail-options|o=s',
           'help|h|?','man|m');