public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Eric Wong <normalperson@yhbt•net>
To: Junio C Hamano <gitster@pobox•com>
Cc: git@vger•kernel.org,
	Remi Lespinet <remi.lespinet@ensimag•grenoble-inp.fr>,
	Matthieu Moy <Matthieu.Moy@imag•fr>
Subject: Re: [RFC] git-send-email: do not double-escape quotes from mutt
Date: Tue, 29 Dec 2015 02:49:30 +0000	[thread overview]
Message-ID: <20151229024930.GA12517@dcvr.yhbt.net> (raw)
In-Reply-To: <xmqqlh8ejj79.fsf@gitster.mtv.corp.google.com>

Junio C Hamano <gitster@pobox•com> wrote:
> 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.

  reply	other threads:[~2015-12-29  2:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-27  2:08 [RFC] git-send-email: do not double-escape quotes from mutt Eric Wong
2015-12-28 22:34 ` Junio C Hamano
2015-12-29  2:49   ` Eric Wong [this message]
2016-01-04 18:11 ` Matthieu Moy
2016-01-04 20:53   ` [PATCH v2] " Eric Wong
2016-01-04 21:35     ` Junio C Hamano
2016-01-04 22:01       ` Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151229024930.GA12517@dcvr.yhbt.net \
    --to=normalperson@yhbt$(echo .)net \
    --cc=Matthieu.Moy@imag$(echo .)fr \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitster@pobox$(echo .)com \
    --cc=remi.lespinet@ensimag$(echo .)grenoble-inp.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox