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

Re: [PATCH] send-email: Honor multi-part email messages

From
KMKrzysztof Mazur <krzysiek@podlesie.net>
Date
Jan 25, 2013, 17:47 UTC
Message-ID
<20130125174700.GA3700@shrek.podlesie.net>
In-Reply-To
<4de442db9fd0896f78166e6038b6ea35ed5ab266.1359126360.git.Alex.Crezoff@gmail.com>
On Fri, Jan 25, 2013 at 07:28:54PM +0400, Alexey Shumkin wrote:
Show 7 quoted lines
> "git format-patch --attach/--inline" generates multi-part messages.
> Every part of such messages can contain non-ASCII characters with its own
> "Content-Type" and "Content-Transfer-Encoding" headers.
> But git-send-mail script interprets a patch-file as one-part message
> and does not recognize multi-part messages.
> So already quoted printable email subject may be encoded as quoted printable
> again. Due to this bug email subject looks corrupted in email clients.

I don't think that the problem with the Subject is multi-part message specific. The real problem with the Subject is probably that is_rfc2047_quoted() does not detect that the Subject is already quoted.

Of course we still need that explicit multi-part message support to avoid "Which 8bit encoding should I declare [UTF-8]? " message.

Show 23 quoted lines
> 
> diff --git a/git-send-email.perl b/git-send-email.perl
> index 94c7f76..d49befe 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -1499,12 +1499,17 @@ sub file_has_nonascii {
>  
>  sub body_or_subject_has_nonascii {
>  	my $fn = shift;
> +	my $multipart = 0;
>  	open(my $fh, '<', $fn)
>  		or die "unable to open $fn: $!\n";
>  	while (my $line = <$fh>) {
>  		last if $line =~ /^$/;
> +		if ($line =~ /^Content-Type:\s*multipart\/mixed.*$/) {
> +			$multipart = 1;
> +		}
>  		return 1 if $line =~ /^Subject.*[^[:ascii:]]/;
>  	}
> +	return 0 if $multipart;
>  	while (my $line = <$fh>) {
>  		return 1 if $line =~ /[^[:ascii:]]/;
>  	}
After this change the function name is no longer appropriate.
Maybe we should join body_or_subject_has_nonascii()
and file_declares_8bit_cte() because in case of multi-part messages
	"next unless (body_or_subject_has_nonascii($f)
		     && !file_declares_8bit_cte($f));"
is not valid anymore. We could also check for broken_encoding
in single pass.
Thanks,
Krzysiek
Previous: Alexey ShumkinNext: Jeff King
Message 3 of 5 in “send-email: Honor multi-part email messages”
  1. send-email: Honor multi-part email messagesAlexey Shumkin, Jan 25, 2013
  2. send-email: Honor multi-part email messagesAlexey Shumkin, Jan 25, 2013
  3. Krzysztof MazurJan 25, 2013
  4. Jeff KingJan 25, 2013
  5. Junio C HamanoJan 25, 2013

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.