git-send-email: do not double-escape quotes from mutt
mutt saves aliases with escaped quotes in the form of: alias dot \"Dot U. Sir\" <somebody@example.org> When we pass through our sanitize_address routine, we end up with double-escaping: To: "\\\"Dot U. Sir\\\" <somebody@example.org> Remove the escaping in mutt only for now, as I am not sure if other mailers can do this or if this is better fixed in sanitize_address. Cc: Remi Lespinet <remi.lespinet@ensimag.grenoble-inp.fr> Cc: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Eric Wong committed
Jan 4, 2016 at 20:53 UTC
2c510f21cd2c571549cf75ff94061a2a6717851f
2 files changed
+22
-2
git-send-email.perl
+7
-2
@@ -493,8 +493,13 @@ my %parse_alias = (
493
if (/^\s*alias\s+(?:-group\s+\S+\s+)*(\S+)\s+(.*)$/) {
494
my ($alias, $addr) = ($1, $2);
495
$addr =~ s/#.*$//; # mutt allows # comments
496
- # commas delimit multiple addresses
497
- $aliases{$alias} = [ split_addrs($addr) ];
496
+ # commas delimit multiple addresses
497
+ my @addr = split_addrs($addr);
498
+
499
+ # quotes may be escaped in the file,
500
+ # unescape them so we do not double-escape them later.
501
+ s/\\"/"/g foreach @addr;
502
+ $aliases{$alias} = \@addr
503
}}},
504
mailrc => sub { my $fh = shift; while (<$fh>) {
505
if (/^alias\s+(\S+)\s+(.*)$/) {
t/t9001-send-email.sh
+15
@@ -1521,6 +1521,21 @@ test_expect_success $PREREQ 'cccover adds Cc to all mail' '
1521
test_cover_addresses "Cc"
1522
'
1523
1524
+test_expect_success $PREREQ 'escaped quotes in sendemail.aliasfiletype=mutt' '
1525
+ clean_fake_sendmail &&
1526
+ echo "alias sbd \\\"Dot U. Sir\\\" <somebody@example.org>" >.mutt &&
1527
+ git config --replace-all sendemail.aliasesfile "$(pwd)/.mutt" &&
1528
+ git config sendemail.aliasfiletype mutt &&
1529
+ git send-email \
1530
+ --from="Example <nobody@example.com>" \
1531
+ --to=sbd \
1532
+ --smtp-server="$(pwd)/fake.sendmail" \
1533
+ outdir/0001-*.patch \
1534
+ 2>errors >out &&
1535
+ grep "^!somebody@example\.org!$" commandline1 &&
1536
+ grep -F "To: \"Dot U. Sir\" <somebody@example.org>" out
1537
+'
1538
+
1539
test_expect_success $PREREQ 'sendemail.aliasfiletype=mailrc' '
1540
clean_fake_sendmail &&
1541
echo "alias sbd somebody@example.org" >.mailrc &&