Skip to contentSkip to conversation

send-email: Avoid empty transfer encoding header

PATCH Superseded Aaron Lindsay 2 participants 3 messages Nov 2, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 send-email: Avoid empty transfer encoding header

Fix a small bug introduced by "7a36987ff (send-email: add an auto option for transfer encoding, 2018-07-14)

I saw the following message when setting --transfer-encoding for a file with the same encoding:

    $ git send-email --transfer-encoding=8bit example.patch
    Use of uninitialized value $xfer_encoding in concatenation (.) or string
    at /usr/lib/git-core/git-send-email line 1744.
---
 git-send-email.perl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
git-send-email.perl +1 -1
index 2be5dac33..39c15bcc8 100755
@@ -1834,7 +1834,7 @@ sub apply_transfer_encoding {
 	my $from = shift;
 	my $to = shift;
 
-	return $message if ($from eq $to and $from ne '7bit');
+	return ($message, $to) if ($from eq $to and $from ne '7bit');
 
 	require MIME::QuotedPrint;
 	require MIME::Base64;
Signature · 1 line
2.19.1
#1 lore raw
Quoted 19 lines · Aaron Lindsay

Fix a small bug introduced by "7a36987ff (send-email: add an auto option for transfer encoding, 2018-07-14)

I saw the following message when setting --transfer-encoding for a file with the same encoding:

    $ git send-email --transfer-encoding=8bit example.patch
    Use of uninitialized value $xfer_encoding in concatenation (.) or string
    at /usr/lib/git-core/git-send-email line 1744.
---
 git-send-email.perl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
git-send-email.perl +0 -0
index 2be5dac33..39c15bcc8 100755

git-send-email.perl sub apply_transfer_encoding { · line 1837

Quoted 5 lines
git-send-email.perl +1 -1
@@ -1834,7 +1834,7 @@ sub apply_transfer_encoding {
 	my $from = shift;
 	my $to = shift;
 
-	return $message if ($from eq $to and $from ne '7bit');
+	return ($message, $to) if ($from eq $to and $from ne '7bit');

Thanks, this is obviously correct.

Would you like to squash in the below patch to add a test?

----- >% -----
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: "brian m. carlson" <[email protected]>
Date: Fri, 2 Nov 2018 01:51:33 +0000
Subject: [PATCH] squash! send-email: Avoid empty transfer encoding header

---
 t/t9001-send-email.sh | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
t/t9001-send-email.sh +15 -0
index 1ef1a19003..ee1efcc59d 100755
@@ -492,6 +492,21 @@ do
 			--validate \
 			$patches longline.patch
 	'
+
+done
+
+for enc in 7bit 8bit quoted-printable base64
+do
+	test_expect_success $PREREQ "--transfer-encoding=$enc produces correct header" '
+		clean_fake_sendmail &&
+		git send-email \
+			--from="Example <[email protected]>" \
+			[email protected] \
+			--smtp-server="$(pwd)/fake.sendmail" \
+			--transfer-encoding=$enc \
+			$patches &&
+		grep "Content-Transfer-Encoding: $enc" msgtxt1
+	'
 done
 
 test_expect_success $PREREQ 'Invalid In-Reply-To' '
Signature · 2 lines
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204
#2 lore raw

PATCH v2 1/1 send-email: Avoid empty transfer encoding header

Fix a small bug introduced by "7a36987ff (send-email: add an auto option for transfer encoding, 2018-07-14)"

I saw the following message when setting --transfer-encoding for a file with the same encoding:

    $ git send-email --transfer-encoding=8bit example.patch
    Use of uninitialized value $xfer_encoding in concatenation (.) or string
    at /usr/lib/git-core/git-send-email line 1744.

v2 adds a test provided by brian m. carlson.

---
 git-send-email.perl   |  2 +-
 t/t9001-send-email.sh | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)
git-send-email.perl +1 -1
index 2be5dac33..39c15bcc8 100755
@@ -1834,7 +1834,7 @@ sub apply_transfer_encoding {
 	my $from = shift;
 	my $to = shift;
 
-	return $message if ($from eq $to and $from ne '7bit');
+	return ($message, $to) if ($from eq $to and $from ne '7bit');
 
 	require MIME::QuotedPrint;
 	require MIME::Base64;
t/t9001-send-email.sh +15 -0
index 1ef1a1900..ee1efcc59 100755
@@ -492,6 +492,21 @@ do
 			--validate \
 			$patches longline.patch
 	'
+
+done
+
+for enc in 7bit 8bit quoted-printable base64
+do
+	test_expect_success $PREREQ "--transfer-encoding=$enc produces correct header" '
+		clean_fake_sendmail &&
+		git send-email \
+			--from="Example <[email protected]>" \
+			[email protected] \
+			--smtp-server="$(pwd)/fake.sendmail" \
+			--transfer-encoding=$enc \
+			$patches &&
+		grep "Content-Transfer-Encoding: $enc" msgtxt1
+	'
 done
 
 test_expect_success $PREREQ 'Invalid In-Reply-To' '
Signature · 1 line
2.19.1