Skip to content

Commit fa5b1aa

Browse files
Awaryngitster
authored andcommitted
send-email: suppress meaningless whitespaces in from field
Remove leading and trailing whitespaces in from field before interepreting it to improve consistency with other options. The split_addrs function already take care of trailing and leading whitespaces for to, cc and bcc fields. The from option now: - has the same behavior when passing arguments like " [email protected] ", "\t [email protected] " or "[email protected]". - interprets aliases in string containing leading and trailing whitespaces such as " alias" or "alias\t" like other options. Signed-off-by: Remi Lespinet <[email protected]> Signed-off-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b1c8a11 commit fa5b1aa

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

git-send-email.perl

+1
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,7 @@ sub file_declares_8bit_cte {
761761
}
762762

763763
if (defined $sender) {
764+
$sender =~ s/^\s+|\s+$//g;
764765
($sender) = expand_aliases($sender);
765766
} else {
766767
$sender = $repoauthor || $repocommitter || '';

t/t9001-send-email.sh

+24
Original file line numberDiff line numberDiff line change
@@ -1692,4 +1692,28 @@ test_expect_success $PREREQ 'aliases work with email list' '
16921692
test_cmp expected-list actual-list
16931693
'
16941694

1695+
test_expect_success $PREREQ 'leading and trailing whitespaces are removed' '
1696+
echo "alias to2 [email protected]" >.mutt &&
1697+
echo "alias cc1 Cc 1 <[email protected]>" >>.mutt &&
1698+
test_config sendemail.aliasesfile ".mutt" &&
1699+
test_config sendemail.aliasfiletype mutt &&
1700+
TO1=$(echo "QTo 1 <[email protected]>" | q_to_tab) &&
1701+
TO2=$(echo "QZto2" | qz_to_tab_space) &&
1702+
CC1=$(echo "cc1" | append_cr) &&
1703+
BCC1=$(echo "Q [email protected] Q" | q_to_nul) &&
1704+
git send-email \
1705+
--dry-run \
1706+
--from=" Example <[email protected]>" \
1707+
--to="$TO1" \
1708+
--to="$TO2" \
1709+
--to=" [email protected] " \
1710+
--cc="$CC1" \
1711+
--cc="Cc2 <[email protected]>" \
1712+
--bcc="$BCC1" \
1713+
1714+
0001-add-master.patch | replace_variable_fields \
1715+
>actual-list &&
1716+
test_cmp expected-list actual-list
1717+
'
1718+
16951719
test_done

0 commit comments

Comments
 (0)