git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Krzysztof Mazur <krzysiek@podlesie.net>
Cc: gitster@pobox.com, git@vger.kernel.org
Subject: Re: [PATCH] git-send-email: skip RFC2047 quoting for ASCII subjects
Date: Wed, 24 Oct 2012 15:25:30 -0400	[thread overview]
Message-ID: <20121024192530.GA26477@sigill.intra.peff.net> (raw)
In-Reply-To: <20121024171036.GA18880@shrek.podlesie.net>

On Wed, Oct 24, 2012 at 07:10:36PM +0200, Krzysztof Mazur wrote:

> > > -	if ($broken_encoding{$t} && !is_rfc2047_quoted($subject)) {
> > > +	if ($broken_encoding{$t} && !is_rfc2047_quoted($subject) &&
> > > +			($subject =~ /[^[:ascii:]]/)) {
> > 
> > Is that test sufficient? We would also need to encode if it has rfc2047
> > specials, no?
> 
> For Subject this should be sufficient. According to RFC822 after
> "Subject:" we have "text" token,
> [...]
> So the problem only exists for broken RFC2047-like texts, but I think
> it's ok to just pass such subjects, in most cases the Subject comes
> from already formatted patch file. I think that we just want to fix Subjects
> without specified encoding here.

Right, but I was specifically worried about raw "=?", which is only an
issue due to rfc2047 itself.

However, reading the patch again, we are already checking for that with
is_rfc2047_quoted. It might miss the case where we have =? but not the
rest of a valid encoded word, but any compliant parser should recognize
that and leave it be.

So I think your original patch is actually correct.

> I think we can go even further, we can just add quote_subject(),
> which performs this test and calls quote_rfc2047() if necessary.
> I'm sending bellow patch that does that.

Yeah, it would still be nice to keep the logic in one place.

> diff --git a/git-send-email.perl b/git-send-email.perl
> index efeae4c..e9aec8d 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -657,9 +657,7 @@ EOT
>  			$initial_subject = $1;
>  			my $subject = $initial_subject;
>  			$_ = "Subject: " .
> -				($subject =~ /[^[:ascii:]]/ ?
> -				 quote_rfc2047($subject, $compose_encoding) :
> -				 $subject) .
> +				quote_subject($subject, $compose_encoding) .

Hrm. Isn't this one technically a regression if the $subject contains
encoded words? IOW, in this case we feed quote_subject a known-raw
header; any rfc2047 in it would want to be encoded to be preserved.

But in this case:

> @@ -1327,9 +1341,8 @@ foreach my $t (@files) {
>  		$body_encoding = $auto_8bit_encoding;
>  	}
>  
> -	if ($broken_encoding{$t} && !is_rfc2047_quoted($subject) &&
> -			($subject =~ /[^[:ascii:]]/)) {
> -		$subject = quote_rfc2047($subject, $auto_8bit_encoding);
> +	if ($broken_encoding{$t}) {
> +		$subject = quote_subject($subject, $auto_8bit_encoding);
>  	}

We have a possibly already-encoded header, and we would want to avoid
double-encoding it.

In the first case, the "wants quoting" logic should be:

  is_rfc2047_quoted($subject) || /[^[:ascii:]]/

and in the latter case it would be:

  !is_rfc2047_quoted($subject) && /^[:ascii:]]/

-Peff

  reply	other threads:[~2012-10-24 19:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-24  8:03 [PATCH] git-send-email: skip RFC2047 quoting for ASCII subjects Krzysztof Mazur
2012-10-24  8:46 ` Jeff King
2012-10-24 17:10   ` Krzysztof Mazur
2012-10-24 19:25     ` Jeff King [this message]
2012-10-24 21:08       ` Krzysztof Mazur
2012-10-24 21:28         ` [PATCH] git-send-email: add rfc2047 quoting for "=?" Krzysztof Mazur
2012-10-25  9:05           ` Jeff King
2012-10-25  9:01         ` [PATCH] git-send-email: skip RFC2047 quoting for ASCII subjects Jeff King
2012-10-25 10:08           ` Jeff King
2012-10-25 11:19             ` Krzysztof Mazur
2012-10-25 11:21               ` Jeff King
2012-10-25 11:12           ` Krzysztof Mazur

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20121024192530.GA26477@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=krzysiek@podlesie.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).