Skip to contentSkip to conversation

send-email: Honor multi-part email messages

PATCH New Alexey Shumkin 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 send-email: Honor multi-part email messages

"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.

---
 git-send-email.perl   |    5 +++
 t/t9001-send-email.sh |   66 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 71 insertions(+), 0 deletions(-)
git-send-email.perl +5 -0
index 98ab33a..1abf4a4 100755
@@ -1403,12 +1403,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:]]/;
 	}
t/t9001-send-email.sh +66 -0

70 lines not on this page · raw message

Signature · 1 line
1.7.6.3.4.gf71f