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

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

From
EWEric Wong <normalperson@yhbt.net>
Date
Dec 29, 2015, 02:49 UTC
Message-ID
<20151229024930.GA12517@dcvr.yhbt.net>
In-Reply-To
<xmqqlh8ejj79.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> wrote:
Show 16 quoted lines
> Eric Wong <normalperson@yhbt.net> writes:
> 
> > -			 # 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,
> > +			# remove them if paired so we do not
> > +			# double-escape them later.
> > +			s/^\\"(.*)\\"/"$1"/g foreach @addr;
> > +			$aliases{$alias} = \@addr
> 
> Can one address have two or more double-quoted string pieces in it?
> If that is possible, (.*) above might want to become (.*?) or even
> ([^"]*) to make it less greedy, perhaps?

Yes. Apparently it's possible to have a double-quote inside the name, too. mutt understands both of the following:

alias qn \"Q. N\\\"ame\" <qn@example.org> # becomes "Q. N\"ame" alias dq \"Dub O.\" \"Q\" <dq@example.org> # becomes "Dub O. Q"

The "qn" case can be taken care of using a simpler replacement on top my original RFC:

--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -530,7 +530,7 @@ my %parse_alias = (
 			# quotes may be escaped in the file,
 			# remove them if paired so we do not
 			# double-escape them later.
-			s/^\\"(.*?)\\"/"$1"/g foreach @addr;
+			s/\\"/"/g foreach @addr;
 			$aliases{$alias} = \@addr
 		}}},
 	mailrc => sub { my $fh = shift; while (<$fh>) {

But I'm not sure how to handle the "dq" case or if that even
happens in practice, as attempting to save an alias with "Dub O." "Q"
in the From: header, mutt shortens it to the expected \"Dub O. Q\"
without extra quotes.

Saving "qn" round trips, so the \\\" in the middle is preserved.
Previous: Junio C HamanoNext: Matthieu Moy
Message 3 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.