git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] git-send-email: do not double-escape quotes from mutt

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 4, 2016, 21:35 UTC
Message-ID
<xmqqy4c5m3iv.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20160104205330.GA6658@dcvr.yhbt.net>
Eric Wong <normalperson@yhbt.net> writes:
Show 16 quoted lines
> 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>
> ---
Forgot to sign-off (I could forge it, though, but anyway)?
Show 65 quoted lines
>   Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:
>   > I think you meant "remove the escaping" or simply "unescape", not
>   > "remove them", which I'd understand as "remove the quotes".
>   > 
>   > Other than that, the patch looks good to me, including your proposed
>   > fixup:
>
>   Thanks, updated the comment and squashed my fixup
>
>   > I wouldn't worry too much about corner-cases, but perhaps some people do
>   > use escaped quotes inside escaped quotes. I'd say they get what they
>   > deserve ;-).
>
>   Agreed :)
>
>  git-send-email.perl   |  9 +++++++--
>  t/t9001-send-email.sh | 15 +++++++++++++++
>  2 files changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/git-send-email.perl b/git-send-email.perl
> index 6caa5b5..d356901 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -524,8 +524,13 @@ my %parse_alias = (
>  		if (/^\s*alias\s+(?:-group\s+\S+\s+)*(\S+)\s+(.*)$/) {
>  			my ($alias, $addr) = ($1, $2);
>  			$addr =~ s/#.*$//; # mutt allows # comments
> -			 # commas delimit multiple addresses
> -			$aliases{$alias} = [ split_addrs($addr) ];
> +			# commas delimit multiple addresses
> +			my @addr = split_addrs($addr);
> +
> +			# quotes may be escaped in the file,
> +			# unescape them so we do not double-escape them later.
> +			s/\\"/"/g foreach @addr;
> +			$aliases{$alias} = \@addr
>  		}}},
>  	mailrc => sub { my $fh = shift; while (<$fh>) {
>  		if (/^alias\s+(\S+)\s+(.*)$/) {
> diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
> index 3c49536..834d91a 100755
> --- a/t/t9001-send-email.sh
> +++ b/t/t9001-send-email.sh
> @@ -1527,6 +1527,21 @@ test_expect_success $PREREQ 'cccover adds Cc to all mail' '
>  	test_cover_addresses "Cc"
>  '
>  
> +test_expect_success $PREREQ 'escaped quotes in sendemail.aliasfiletype=mutt' '
> +	clean_fake_sendmail &&
> +	echo "alias sbd \\\"Dot U. Sir\\\" <somebody@example.org>" >.mutt &&
> +	git config --replace-all sendemail.aliasesfile "$(pwd)/.mutt" &&
> +	git config sendemail.aliasfiletype mutt &&
> +	git send-email \
> +		--from="Example <nobody@example.com>" \
> +		--to=sbd \
> +		--smtp-server="$(pwd)/fake.sendmail" \
> +		outdir/0001-*.patch \
> +		2>errors >out &&
> +	grep "^!somebody@example\.org!$" commandline1 &&
> +	grep -F "To: \"Dot U. Sir\" <somebody@example.org>" out
> +'
> +
>  test_expect_success $PREREQ 'sendemail.aliasfiletype=mailrc' '
>  	clean_fake_sendmail &&
>  	echo "alias sbd  somebody@example.org" >.mailrc &&
Previous: Eric WongNext: Eric Wong
Message 6 of 7 in “[RFC] git-send-email: do not double-escape quotes from mutt”
  1. Eric WongDec 27, 2015
  2. Junio C HamanoDec 28, 2015
  3. Eric WongDec 29, 2015
  4. Matthieu MoyJan 4, 2016
  5. git-send-email: do not double-escape quotes from muttEric Wong, Jan 4, 2016
  6. Junio C HamanoJan 4, 2016
  7. Eric WongJan 4, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.