Skip to content

Commit 2c510f2

Browse files
Eric Wonggitster
authored andcommitted
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\" <[email protected]> When we pass through our sanitize_address routine, we end up with double-escaping: To: "\\\"Dot U. Sir\\\" <[email protected]> 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 <[email protected]> Cc: Matthieu Moy <[email protected]> Signed-off-by: Eric Wong <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a2558fb commit 2c510f2

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

git-send-email.perl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,8 +493,13 @@ sub split_addrs {
493493
if (/^\s*alias\s+(?:-group\s+\S+\s+)*(\S+)\s+(.*)$/) {
494494
my ($alias, $addr) = ($1, $2);
495495
$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
498503
}}},
499504
mailrc => sub { my $fh = shift; while (<$fh>) {
500505
if (/^alias\s+(\S+)\s+(.*)$/) {

t/t9001-send-email.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,6 +1521,21 @@ test_expect_success $PREREQ 'cccover adds Cc to all mail' '
15211521
test_cover_addresses "Cc"
15221522
'
15231523

1524+
test_expect_success $PREREQ 'escaped quotes in sendemail.aliasfiletype=mutt' '
1525+
clean_fake_sendmail &&
1526+
echo "alias sbd \\\"Dot U. Sir\\\" <[email protected]>" >.mutt &&
1527+
git config --replace-all sendemail.aliasesfile "$(pwd)/.mutt" &&
1528+
git config sendemail.aliasfiletype mutt &&
1529+
git send-email \
1530+
--from="Example <[email protected]>" \
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\" <[email protected]>" out
1537+
'
1538+
15241539
test_expect_success $PREREQ 'sendemail.aliasfiletype=mailrc' '
15251540
clean_fake_sendmail &&
15261541
echo "alias sbd [email protected]" >.mailrc &&

0 commit comments

Comments
 (0)