{"thread":{"id":"48832","subject":"[PATCH 0/3] Automatic transfer encoding for patches","startedAt":"2018-07-06T02:24:15Z","lastAt":"2018-07-08T22:23:00Z","messageCount":16,"participants":["brian m. carlson","Eric Sunshine","Drew DeVault"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"351746","messageId":"20180706022357.739657-1-sandals@crustytoothpaste.net","threadId":"48832","inReplyTo":null,"subject":"[PATCH 0/3] Automatic transfer encoding for patches","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-06T02:23:54Z","receivedAt":"2018-07-06T02:24:15Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"git send-email has the --validate option, which is the default, to check\nif a patch has lines longer than RFC 5321 allows (998 octets).  However,\nit doesn't take into account the fact that using certain transfer\nencodings makes this issue moot, and it also doesn't provide any helpful\nclue to the user about what to do when this fails.\n\nThis series introduces an \"auto\" value for --transfer-encoding that uses\n8bit when possible (i.e. when lines are 998 octets or shorter) and\nquoted-printable otherwise; it then makes this the default behavior.  It\nalso makes --validate aware of transfer encoding so it doesn't complain\nwhen using quoted-printable or base64.\n\ngit am already understands how to handle patches in any valid transfer\nencoding.\n\nAs a result of this series, we always produce MIME messages with a\nContent-Transfer-Encoding header.  I don't think this will cause any\nproblems, but if someone knows of a reason why it would, please shout\nloudly.\n\nbrian m. carlson (3):\n  send-email: add an auto option for transfer encoding\n  send-email: accept long lines with suitable transfer encoding\n  send-email: automatically determine transfer-encoding\n\n Documentation/git-send-email.txt | 15 +++++----\n git-send-email.perl              | 36 ++++++++++----------\n t/t9001-send-email.sh            | 58 ++++++++++++++++++++++++++++++++\n 3 files changed, 85 insertions(+), 24 deletions(-)\n\n"},{"id":"351747","messageId":"20180706022357.739657-2-sandals@crustytoothpaste.net","threadId":"48832","inReplyTo":"20180706022357.739657-1-sandals@crustytoothpaste.net","subject":"[PATCH 1/3] send-email: add an auto option for transfer encoding","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-06T02:23:55Z","receivedAt":"2018-07-06T02:24:16Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"For most patches, using a transfer encoding of 8bit provides good\ncompatibility with most servers and makes it as easy as possible to view\npatches.  However, there are some patches for which 8bit is not a valid\nencoding: RFC 5321 specifies that a message must not have lines\nexceeding 998 octets.\n\nAdd a transfer encoding value, auto, which indicates that a patch should\nuse 8bit where allowed and quoted-printable otherwise.  Choose\nquoted-printable instead of base64, since base64-encoded plain text is\ntreated as suspicious by some spam filters.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n Documentation/git-send-email.txt | 11 +++++++----\n git-send-email.perl              | 12 +++++++-----\n t/t9001-send-email.sh            | 24 ++++++++++++++++++++++++\n 3 files changed, 38 insertions(+), 9 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 4f3efde80c..385c7de9e2 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -137,15 +137,18 @@ Note that no attempts whatsoever are made to validate the encoding.\n \tSpecify encoding of compose message. Default is the value of the\n \t'sendemail.composeencoding'; if that is unspecified, UTF-8 is assumed.\n \n---transfer-encoding=(7bit|8bit|quoted-printable|base64)::\n+--transfer-encoding=(7bit|8bit|quoted-printable|base64|auto)::\n \tSpecify the transfer encoding to be used to send the message over SMTP.\n \t7bit will fail upon encountering a non-ASCII message.  quoted-printable\n \tcan be useful when the repository contains files that contain carriage\n \treturns, but makes the raw patch email file (as saved from a MUA) much\n \tharder to inspect manually.  base64 is even more fool proof, but also\n-\teven more opaque.  Default is the value of the `sendemail.transferEncoding`\n-\tconfiguration value; if that is unspecified, git will use 8bit and not\n-\tadd a Content-Transfer-Encoding header.\n+\teven more opaque.  auto will use 8bit when possible, and quoted-printable\n+\totherwise.\n++\n+Default is the value of the `sendemail.transferEncoding` configuration\n+value; if that is unspecified, git will use 8bit and not add a\n+Content-Transfer-Encoding header.\n \n --xmailer::\n --no-xmailer::\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 8ec70e58ed..a76953c310 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1739,9 +1739,8 @@ sub process_file {\n \t}\n \tif (defined $target_xfer_encoding) {\n \t\t$xfer_encoding = '8bit' if not defined $xfer_encoding;\n-\t\t$message = apply_transfer_encoding(\n+\t\t($message, $xfer_encoding) = apply_transfer_encoding(\n \t\t\t$message, $xfer_encoding, $target_xfer_encoding);\n-\t\t$xfer_encoding = $target_xfer_encoding;\n \t}\n \tif (defined $xfer_encoding) {\n \t\tpush @xh, \"Content-Transfer-Encoding: $xfer_encoding\";\n@@ -1852,13 +1851,16 @@ sub apply_transfer_encoding {\n \t$message = MIME::Base64::decode($message)\n \t\tif ($from eq 'base64');\n \n+\t$to = ($message =~ /.{999,}/) ? 'quoted-printable' :'8bit'\n+\t\tif $to eq 'auto';\n+\n \tdie __(\"cannot send message as 7bit\")\n \t\tif ($to eq '7bit' and $message =~ /[^[:ascii:]]/);\n-\treturn $message\n+\treturn ($message, $to)\n \t\tif ($to eq '7bit' or $to eq '8bit');\n-\treturn MIME::QuotedPrint::encode($message, \"\\n\", 0)\n+\treturn (MIME::QuotedPrint::encode($message, \"\\n\", 0), $to)\n \t\tif ($to eq 'quoted-printable');\n-\treturn MIME::Base64::encode($message, \"\\n\")\n+\treturn (MIME::Base64::encode($message, \"\\n\"), $to)\n \t\tif ($to eq 'base64');\n \tdie __(\"invalid transfer encoding\");\n }\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex e80eacbb1b..6cdcbcb19e 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -456,6 +456,30 @@ test_expect_success $PREREQ 'allow long lines with --no-validate' '\n \t\t2>errors\n '\n \n+test_expect_success $PREREQ 'short lines with auto encoding are 8bit' '\n+\tclean_fake_sendmail &&\n+\tgit send-email \\\n+\t\t--from=\"A <author@example.com>\" \\\n+\t\t--to=nobody@example.com \\\n+\t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n+\t\t--transfer-encoding=auto \\\n+\t\t$patches &&\n+\tgrep \"Content-Transfer-Encoding: 8bit\" msgtxt1\n+'\n+\n+test_expect_success $PREREQ 'long lines with auto encoding are quoted-printable' '\n+\tclean_fake_sendmail &&\n+\tgit send-email \\\n+\t\t--from=\"Example <nobody@example.com>\" \\\n+\t\t--to=nobody@example.com \\\n+\t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n+\t\t--transfer-encoding=auto \\\n+\t\t--no-validate \\\n+\t\tlongline.patch \\\n+\t\t2>errors &&\n+\tgrep \"Content-Transfer-Encoding: quoted-printable\" msgtxt1\n+'\n+\n test_expect_success $PREREQ 'Invalid In-Reply-To' '\n \tclean_fake_sendmail &&\n \tgit send-email \\\n"},{"id":"351748","messageId":"20180706022357.739657-4-sandals@crustytoothpaste.net","threadId":"48832","inReplyTo":"20180706022357.739657-1-sandals@crustytoothpaste.net","subject":"[PATCH 3/3] send-email: automatically determine transfer-encoding","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-06T02:23:57Z","receivedAt":"2018-07-06T02:24:20Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"git send-email, when invoked without a --transfer-encoding option, sends\n8bit data without a MIME version or a transfer encoding.  This has\nseveral downsides.\n\nFirst, unless the transfer encoding is specified, it defaults to 7bit,\nmeaning that non-ASCII data isn't allowed.  Second, if lines longer than\n998 bytes are used, we will send an message that is invalid according to\nRFC 5321.  The --validate option, which is the default, catches this\nissue, but it isn't clear to many people how to resolve this.\n\nTo solve these issues, default the transfer encoding to \"auto\", so that\nwe explicitly specify 8bit encoding when lines don't exceed 998 bytes\nand quoted-printable otherwise.  This means that we now always emit\nContent-Transfer-Encoding and MIME-Version headers, so remove the\nconditionals from this portion of the code.\n\nIt is unlikely that the unconditional inclusion of these two headers\nwill affect the deliverability of messages in anything but a positive\nway, since MIME is already widespread and well understood by most email\nprograms.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n Documentation/git-send-email.txt |  3 +--\n git-send-email.perl              | 18 ++++++------------\n t/t9001-send-email.sh            | 21 +++++++++++++++++++++\n 3 files changed, 28 insertions(+), 14 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex f44fb4b81e..1a240b52fc 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -147,8 +147,7 @@ Note that no attempts whatsoever are made to validate the encoding.\n \totherwise.\n +\n Default is the value of the `sendemail.transferEncoding` configuration\n-value; if that is unspecified, git will use 8bit and not add a\n-Content-Transfer-Encoding header.\n+value; if that is unspecified, default to `auto`.\n \n --xmailer::\n --no-xmailer::\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 4ea30c4070..c4fae17787 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -231,7 +231,7 @@ sub do_edit {\n my (@suppress_cc);\n my ($auto_8bit_encoding);\n my ($compose_encoding);\n-my ($target_xfer_encoding);\n+my $target_xfer_encoding = 'auto';\n \n my ($debug_net_smtp) = 0;\t\t# Net::SMTP, see send_message()\n \n@@ -1737,17 +1737,11 @@ sub process_file {\n \t\t\t}\n \t\t}\n \t}\n-\tif (defined $target_xfer_encoding) {\n-\t\t$xfer_encoding = '8bit' if not defined $xfer_encoding;\n-\t\t($message, $xfer_encoding) = apply_transfer_encoding(\n-\t\t\t$message, $xfer_encoding, $target_xfer_encoding);\n-\t}\n-\tif (defined $xfer_encoding) {\n-\t\tpush @xh, \"Content-Transfer-Encoding: $xfer_encoding\";\n-\t}\n-\tif (defined $xfer_encoding or $has_content_type) {\n-\t\tunshift @xh, 'MIME-Version: 1.0' unless $has_mime_version;\n-\t}\n+\t$xfer_encoding = '8bit' if not defined $xfer_encoding;\n+\t($message, $xfer_encoding) = apply_transfer_encoding(\n+\t\t$message, $xfer_encoding, $target_xfer_encoding);\n+\tpush @xh, \"Content-Transfer-Encoding: $xfer_encoding\";\n+\tunshift @xh, 'MIME-Version: 1.0' unless $has_mime_version;\n \n \t$needs_confirm = (\n \t\t$confirm eq \"always\" or\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 6a0ace386b..7edce50e65 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -225,6 +225,8 @@ X-Mailer: X-MAILER-STRING\n In-Reply-To: <unique-message-id@example.com>\n References: <unique-message-id@example.com>\n Reply-To: Reply <reply@example.com>\n+MIME-Version: 1.0\n+Content-Transfer-Encoding: 8bit\n \n Result: OK\n EOF\n@@ -415,6 +417,7 @@ test_expect_success $PREREQ 'reject long lines' '\n \t\t--from=\"Example <nobody@example.com>\" \\\n \t\t--to=nobody@example.com \\\n \t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n+\t\t--transfer-encoding=8bit \\\n \t\t$patches longline.patch \\\n \t\t2>errors &&\n \tgrep longline.patch errors\n@@ -610,6 +613,8 @@ Subject: [PATCH 1/1] Second.\n Date: DATE-STRING\n Message-Id: MESSAGE-ID-STRING\n X-Mailer: X-MAILER-STRING\n+MIME-Version: 1.0\n+Content-Transfer-Encoding: 8bit\n \n Result: OK\n EOF\n@@ -654,6 +659,8 @@ Subject: [PATCH 1/1] Second.\n Date: DATE-STRING\n Message-Id: MESSAGE-ID-STRING\n X-Mailer: X-MAILER-STRING\n+MIME-Version: 1.0\n+Content-Transfer-Encoding: 8bit\n \n Result: OK\n EOF\n@@ -689,6 +696,8 @@ Subject: [PATCH 1/1] Second.\n Date: DATE-STRING\n Message-Id: MESSAGE-ID-STRING\n X-Mailer: X-MAILER-STRING\n+MIME-Version: 1.0\n+Content-Transfer-Encoding: 8bit\n \n Result: OK\n EOF\n@@ -715,6 +724,8 @@ Subject: [PATCH 1/1] Second.\n Date: DATE-STRING\n Message-Id: MESSAGE-ID-STRING\n X-Mailer: X-MAILER-STRING\n+MIME-Version: 1.0\n+Content-Transfer-Encoding: 8bit\n \n Result: OK\n EOF\n@@ -749,6 +760,8 @@ Subject: [PATCH 1/1] Second.\n Date: DATE-STRING\n Message-Id: MESSAGE-ID-STRING\n X-Mailer: X-MAILER-STRING\n+MIME-Version: 1.0\n+Content-Transfer-Encoding: 8bit\n \n Result: OK\n EOF\n@@ -780,6 +793,8 @@ Subject: [PATCH 1/1] Second.\n Date: DATE-STRING\n Message-Id: MESSAGE-ID-STRING\n X-Mailer: X-MAILER-STRING\n+MIME-Version: 1.0\n+Content-Transfer-Encoding: 8bit\n \n Result: OK\n EOF\n@@ -811,6 +826,8 @@ Subject: [PATCH 1/1] Second.\n Date: DATE-STRING\n Message-Id: MESSAGE-ID-STRING\n X-Mailer: X-MAILER-STRING\n+MIME-Version: 1.0\n+Content-Transfer-Encoding: 8bit\n \n Result: OK\n EOF\n@@ -846,6 +863,8 @@ Subject: [PATCH 1/1] Second.\n Date: DATE-STRING\n Message-Id: MESSAGE-ID-STRING\n X-Mailer: X-MAILER-STRING\n+MIME-Version: 1.0\n+Content-Transfer-Encoding: 8bit\n \n Result: OK\n EOF\n@@ -874,6 +893,8 @@ Subject: [PATCH 1/1] Second.\n Date: DATE-STRING\n Message-Id: MESSAGE-ID-STRING\n X-Mailer: X-MAILER-STRING\n+MIME-Version: 1.0\n+Content-Transfer-Encoding: 8bit\n \n Result: OK\n EOF\n"},{"id":"351749","messageId":"20180706022357.739657-3-sandals@crustytoothpaste.net","threadId":"48832","inReplyTo":"20180706022357.739657-1-sandals@crustytoothpaste.net","subject":"[PATCH 2/3] send-email: accept long lines with suitable transfer encoding","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-06T02:23:56Z","receivedAt":"2018-07-06T02:24:22Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"With --validate (which is the default), we warn about lines exceeding\n998 characters due to the limits specified in RFC 5321.  However, if\nwe're using a suitable transfer encoding (quoted-printable or base64),\nwe're guaranteed not to have lines exceeding 76 characters, so there's\nno need to fail in this case.  The auto transfer encoding handles this\nspecific case, so accept it as well.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n Documentation/git-send-email.txt |  5 +++--\n git-send-email.perl              |  8 ++++++--\n t/t9001-send-email.sh            | 13 +++++++++++++\n 3 files changed, 22 insertions(+), 4 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 385c7de9e2..f44fb4b81e 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -401,8 +401,9 @@ have been specified, in which case default to 'compose'.\n +\n --\n \t\t*\tInvoke the sendemail-validate hook if present (see linkgit:githooks[5]).\n-\t\t*\tWarn of patches that contain lines longer than 998 characters; this\n-\t\t\tis due to SMTP limits as described by http://www.ietf.org/rfc/rfc2821.txt.\n+\t\t*\tWarn of patches that contain lines longer than 998 characters unless\n+\t\t\ta suitable transfer encoding is used; this is due to SMTP limits as\n+\t\t\tdescribed by http://www.ietf.org/rfc/rfc2821.txt.\n --\n +\n Default is the value of `sendemail.validate`; if this is not set,\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex a76953c310..4ea30c4070 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -645,7 +645,7 @@ sub is_format_patch_arg {\n if ($validate) {\n \tforeach my $f (@files) {\n \t\tunless (-p $f) {\n-\t\t\tmy $error = validate_patch($f);\n+\t\t\tmy $error = validate_patch($f, $target_xfer_encoding);\n \t\t\t$error and die sprintf(__(\"fatal: %s: %s\\nwarning: no patches were sent\\n\"),\n \t\t\t\t\t\t  $f, $error);\n \t\t}\n@@ -1879,7 +1879,7 @@ sub unique_email_list {\n }\n \n sub validate_patch {\n-\tmy $fn = shift;\n+\tmy ($fn, $xfer_encoding) = @_;\n \n \tif ($repo) {\n \t\tmy $validate_hook = catfile(catdir($repo->repo_path(), 'hooks'),\n@@ -1899,6 +1899,10 @@ sub validate_patch {\n \t\treturn $hook_error if $hook_error;\n \t}\n \n+\t# Any long lines will be automatically fixed if we use a suitable transfer\n+\t# encoding.\n+\treturn if $xfer_encoding =~ /^(?:auto|quoted-printable|base64)$/;\n+\n \topen(my $fh, '<', $fn)\n \t\tor die sprintf(__(\"unable to open %s: %s\\n\"), $fn, $!);\n \twhile (my $line = <$fh>) {\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 6cdcbcb19e..6a0ace386b 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -480,6 +480,19 @@ test_expect_success $PREREQ 'long lines with auto encoding are quoted-printable'\n \tgrep \"Content-Transfer-Encoding: quoted-printable\" msgtxt1\n '\n \n+test_expect_success $PREREQ '--validate passes with certain encodings' '\n+\tfor enc in auto quoted-printable base64\n+\tdo\n+\t\tgit send-email \\\n+\t\t\t--from=\"Example <nobody@example.com>\" \\\n+\t\t\t--to=nobody@example.com \\\n+\t\t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n+\t\t\t--transfer-encoding=$enc \\\n+\t\t\t--validate \\\n+\t\t\t$patches longline.patch\n+\tdone\n+'\n+\n test_expect_success $PREREQ 'Invalid In-Reply-To' '\n \tclean_fake_sendmail &&\n \tgit send-email \\\n"},{"id":"351762","messageId":"CAPig+cR7tWw7D8JMg1a9G2Jgi=HQj3YZjCn+tHDNjDEsrfSLqg@mail.gmail.com","threadId":"48832","inReplyTo":"20180706022357.739657-2-sandals@crustytoothpaste.net","subject":"Re: [PATCH 1/3] send-email: add an auto option for transfer encoding","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2018-07-06T06:01:25Z","receivedAt":"2018-07-06T06:03:43Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Thu, Jul 5, 2018 at 10:24 PM brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n> For most patches, using a transfer encoding of 8bit provides good\n> compatibility with most servers and makes it as easy as possible to view\n> patches.  However, there are some patches for which 8bit is not a valid\n> encoding: RFC 5321 specifies that a message must not have lines\n> exceeding 998 octets.\n>\n> Add a transfer encoding value, auto, which indicates that a patch should\n> use 8bit where allowed and quoted-printable otherwise.  Choose\n> quoted-printable instead of base64, since base64-encoded plain text is\n> treated as suspicious by some spam filters.\n>\n> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n> ---\n> diff --git a/git-send-email.perl b/git-send-email.perl\n> @@ -1852,13 +1851,16 @@ sub apply_transfer_encoding {\n> +       $to = ($message =~ /.{999,}/) ? 'quoted-printable' :'8bit'\n> +               if $to eq 'auto';\n\nStyle: space after colon: 'quoted-printable' : '8bit'\n\n> diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\n> +test_expect_success $PREREQ 'long lines with auto encoding are quoted-printable' '\n> +       clean_fake_sendmail &&\n> +       git send-email \\\n> +               --from=\"Example <nobody@example.com>\" \\\n> +               --to=nobody@example.com \\\n> +               --smtp-server=\"$(pwd)/fake.sendmail\" \\\n> +               --transfer-encoding=auto \\\n> +               --no-validate \\\n> +               longline.patch \\\n> +               2>errors &&\n\nWhy capture stderr to a file then ignore the file?\n\n> +       grep \"Content-Transfer-Encoding: quoted-printable\" msgtxt1\n> +'\n"},{"id":"351763","messageId":"CAPig+cTNGNCUxoBdunAvjAKy5w_oYaLJ7HiAp1vYCtPmDEOUww@mail.gmail.com","threadId":"48832","inReplyTo":"20180706022357.739657-3-sandals@crustytoothpaste.net","subject":"Re: [PATCH 2/3] send-email: accept long lines with suitable transfer encoding","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2018-07-06T06:08:17Z","receivedAt":"2018-07-06T06:10:34Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Thu, Jul 5, 2018 at 10:24 PM brian m. carlson\n<sandals@crustytoothpaste.net> wrote:\n> With --validate (which is the default), we warn about lines exceeding\n> 998 characters due to the limits specified in RFC 5321.  However, if\n> we're using a suitable transfer encoding (quoted-printable or base64),\n> we're guaranteed not to have lines exceeding 76 characters, so there's\n> no need to fail in this case.  The auto transfer encoding handles this\n> specific case, so accept it as well.\n>\n> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n> ---\n> diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\n> @@ -401,8 +401,9 @@ have been specified, in which case default to 'compose'.\n> -               *       Warn of patches that contain lines longer than 998 characters; this\n> -                       is due to SMTP limits as described by http://www.ietf.org/rfc/rfc2821.txt.\n> +               *       Warn of patches that contain lines longer than 998 characters unless\n> +                       a suitable transfer encoding is used; this is due to SMTP limits as\n> +                       described by http://www.ietf.org/rfc/rfc2821.txt.\n\nA reader might like to know what \"a suitable transfer encoding\" is.\nPerhaps add a \"such as 'auto', 'quoted-printable' and 'base64'\"\ncomment?\n\n> diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\n> @@ -480,6 +480,19 @@ test_expect_success $PREREQ 'long lines with auto encoding are quoted-printable'\n> +test_expect_success $PREREQ '--validate passes with certain encodings' '\n> +       for enc in auto quoted-printable base64\n> +       do\n> +               git send-email \\\n> +                       --from=\"Example <nobody@example.com>\" \\\n> +                       --to=nobody@example.com \\\n> +                       --smtp-server=\"$(pwd)/fake.sendmail\" \\\n> +                       --transfer-encoding=$enc \\\n> +                       --validate \\\n> +                       $patches longline.patch\n> +       done\n> +'\n\nIf you turn this inside out, it will be easier to figure out which\nencoding fails (if one ever does). That is:\n\n    for enc in auto quoted-printable base64\n    do\n        test_expect_success $PREREQ \"--validate passes with encoding $enc\" '\n            git send-email ...\n        '\n    done\n"},{"id":"351774","messageId":"20180706122604.GA9255@homura.localdomain","threadId":"48832","inReplyTo":"20180706022357.739657-3-sandals@crustytoothpaste.net","subject":"Re: [PATCH 2/3] send-email: accept long lines with suitable transfer encoding","fromName":"Drew DeVault","fromEmail":"sir@cmpwn.com","sentAt":"2018-07-06T12:26:04Z","receivedAt":"2018-07-06T12:26:09Z","isPatch":true,"sender":{"key":"sir@cmpwn.com","avatar":"https://avatars.githubusercontent.com/u/1310872?v=4"},"body":"On 2018-07-06  2:23 AM, brian m. carlson wrote:\n> diff --git a/git-send-email.perl b/git-send-email.perl\n> index a76953c310..4ea30c4070 100755\n> --- a/git-send-email.perl\n> +++ b/git-send-email.perl\n> @@ -1899,6 +1899,10 @@ sub validate_patch {\n>  \t\treturn $hook_error if $hook_error;\n>  \t}\n>  \n> +\t# Any long lines will be automatically fixed if we use a suitable transfer\n> +\t# encoding.\n> +\treturn if $xfer_encoding =~ /^(?:auto|quoted-printable|base64)$/;\n\nRather than returning in this case I'd sooner wrap the length check in\nthis test. If additional checks are added in the future it'd be too easy\nto accidentally skip them if the transfer encoding is quoted-printable.\n"},{"id":"351775","messageId":"20180706122658.GB9255@homura.localdomain","threadId":"48832","inReplyTo":"20180706022357.739657-1-sandals@crustytoothpaste.net","subject":"Re: [PATCH 0/3] Automatic transfer encoding for patches","fromName":"Drew DeVault","fromEmail":"sir@cmpwn.com","sentAt":"2018-07-06T12:26:58Z","receivedAt":"2018-07-06T12:27:03Z","isPatch":true,"sender":{"key":"sir@cmpwn.com","avatar":"https://avatars.githubusercontent.com/u/1310872?v=4"},"body":"Overall this series looks good. Thanks for putting the patches together!\n"},{"id":"351805","messageId":"20180706201843.GF7697@genre.crustytoothpaste.net","threadId":"48832","inReplyTo":"20180706122604.GA9255@homura.localdomain","subject":"Re: [PATCH 2/3] send-email: accept long lines with suitable transfer encoding","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-06T20:18:43Z","receivedAt":"2018-07-06T20:18:51Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Fri, Jul 06, 2018 at 08:26:04AM -0400, Drew DeVault wrote:\n> On 2018-07-06  2:23 AM, brian m. carlson wrote:\n> > diff --git a/git-send-email.perl b/git-send-email.perl\n> > index a76953c310..4ea30c4070 100755\n> > --- a/git-send-email.perl\n> > +++ b/git-send-email.perl\n> > @@ -1899,6 +1899,10 @@ sub validate_patch {\n> >  \t\treturn $hook_error if $hook_error;\n> >  \t}\n> >  \n> > +\t# Any long lines will be automatically fixed if we use a suitable transfer\n> > +\t# encoding.\n> > +\treturn if $xfer_encoding =~ /^(?:auto|quoted-printable|base64)$/;\n> \n> Rather than returning in this case I'd sooner wrap the length check in\n> this test. If additional checks are added in the future it'd be too easy\n> to accidentally skip them if the transfer encoding is quoted-printable.\n\nOkay, that's fair.  I can do that.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"351806","messageId":"20180706201955.GG7697@genre.crustytoothpaste.net","threadId":"48832","inReplyTo":"CAPig+cR7tWw7D8JMg1a9G2Jgi=HQj3YZjCn+tHDNjDEsrfSLqg@mail.gmail.com","subject":"Re: [PATCH 1/3] send-email: add an auto option for transfer encoding","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-06T20:19:55Z","receivedAt":"2018-07-06T20:20:04Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Fri, Jul 06, 2018 at 02:01:25AM -0400, Eric Sunshine wrote:\n> On Thu, Jul 5, 2018 at 10:24 PM brian m. carlson\n> <sandals@crustytoothpaste.net> wrote:\n> > For most patches, using a transfer encoding of 8bit provides good\n> > compatibility with most servers and makes it as easy as possible to view\n> > patches.  However, there are some patches for which 8bit is not a valid\n> > encoding: RFC 5321 specifies that a message must not have lines\n> > exceeding 998 octets.\n> >\n> > Add a transfer encoding value, auto, which indicates that a patch should\n> > use 8bit where allowed and quoted-printable otherwise.  Choose\n> > quoted-printable instead of base64, since base64-encoded plain text is\n> > treated as suspicious by some spam filters.\n> >\n> > Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n> > ---\n> > diff --git a/git-send-email.perl b/git-send-email.perl\n> > @@ -1852,13 +1851,16 @@ sub apply_transfer_encoding {\n> > +       $to = ($message =~ /.{999,}/) ? 'quoted-printable' :'8bit'\n> > +               if $to eq 'auto';\n> \n> Style: space after colon: 'quoted-printable' : '8bit'\n\nWill fix.\n\n> > diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\n> > +test_expect_success $PREREQ 'long lines with auto encoding are quoted-printable' '\n> > +       clean_fake_sendmail &&\n> > +       git send-email \\\n> > +               --from=\"Example <nobody@example.com>\" \\\n> > +               --to=nobody@example.com \\\n> > +               --smtp-server=\"$(pwd)/fake.sendmail\" \\\n> > +               --transfer-encoding=auto \\\n> > +               --no-validate \\\n> > +               longline.patch \\\n> > +               2>errors &&\n> \n> Why capture stderr to a file then ignore the file?\n\nCopy-paste error from an earlier test.  Will fix.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"351895","messageId":"20180708221713.518276-1-sandals@crustytoothpaste.net","threadId":"48832","inReplyTo":"20180706022357.739657-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 0/4] Automatic transfer encoding for patches","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-08T22:17:09Z","receivedAt":"2018-07-08T22:17:24Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"This series introduces an \"auto\" value for git send-email\n--transfer-encoding that uses 8bit when possible (i.e. when lines are\n998 octets or shorter) and quoted-printable otherwise; it then makes\nthis the default behavior.  It also makes --validate aware of transfer\nencoding so it doesn't complain when using quoted-printable or base64.\n\nChanges from v1:\n* Update commit messages to refer to RFC 5322.\n* Add a missing space.\n* Remove the needless capture of stderr.\n* Define \"suitable transfer encoding\".\n* Invert test to better capture failures.\n* Wrap --validate code in an if block instead of returning early.\n* Update documentation to reflect correct, modern RFC.\n\nbrian m. carlson (4):\n  send-email: add an auto option for transfer encoding\n  send-email: accept long lines with suitable transfer encoding\n  send-email: automatically determine transfer-encoding\n  docs: correct RFC specifying email line length\n\n Documentation/git-send-email.txt | 17 ++++++----\n git-send-email.perl              | 46 +++++++++++++-------------\n t/t9001-send-email.sh            | 57 ++++++++++++++++++++++++++++++++\n 3 files changed, 91 insertions(+), 29 deletions(-)\n\n"},{"id":"351896","messageId":"20180708221713.518276-2-sandals@crustytoothpaste.net","threadId":"48832","inReplyTo":"20180708221713.518276-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 1/4] send-email: add an auto option for transfer encoding","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-08T22:17:10Z","receivedAt":"2018-07-08T22:17:27Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"For most patches, using a transfer encoding of 8bit provides good\ncompatibility with most servers and makes it as easy as possible to view\npatches.  However, there are some patches for which 8bit is not a valid\nencoding: RFC 5322 specifies that a message must not have lines\nexceeding 998 octets.\n\nAdd a transfer encoding value, auto, which indicates that a patch should\nuse 8bit where allowed and quoted-printable otherwise.  Choose\nquoted-printable instead of base64, since base64-encoded plain text is\ntreated as suspicious by some spam filters.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n Documentation/git-send-email.txt | 11 +++++++----\n git-send-email.perl              | 12 +++++++-----\n t/t9001-send-email.sh            | 23 +++++++++++++++++++++++\n 3 files changed, 37 insertions(+), 9 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 4f3efde80c..385c7de9e2 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -137,15 +137,18 @@ Note that no attempts whatsoever are made to validate the encoding.\n \tSpecify encoding of compose message. Default is the value of the\n \t'sendemail.composeencoding'; if that is unspecified, UTF-8 is assumed.\n \n---transfer-encoding=(7bit|8bit|quoted-printable|base64)::\n+--transfer-encoding=(7bit|8bit|quoted-printable|base64|auto)::\n \tSpecify the transfer encoding to be used to send the message over SMTP.\n \t7bit will fail upon encountering a non-ASCII message.  quoted-printable\n \tcan be useful when the repository contains files that contain carriage\n \treturns, but makes the raw patch email file (as saved from a MUA) much\n \tharder to inspect manually.  base64 is even more fool proof, but also\n-\teven more opaque.  Default is the value of the `sendemail.transferEncoding`\n-\tconfiguration value; if that is unspecified, git will use 8bit and not\n-\tadd a Content-Transfer-Encoding header.\n+\teven more opaque.  auto will use 8bit when possible, and quoted-printable\n+\totherwise.\n++\n+Default is the value of the `sendemail.transferEncoding` configuration\n+value; if that is unspecified, git will use 8bit and not add a\n+Content-Transfer-Encoding header.\n \n --xmailer::\n --no-xmailer::\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 8ec70e58ed..1736a09d21 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -1739,9 +1739,8 @@ sub process_file {\n \t}\n \tif (defined $target_xfer_encoding) {\n \t\t$xfer_encoding = '8bit' if not defined $xfer_encoding;\n-\t\t$message = apply_transfer_encoding(\n+\t\t($message, $xfer_encoding) = apply_transfer_encoding(\n \t\t\t$message, $xfer_encoding, $target_xfer_encoding);\n-\t\t$xfer_encoding = $target_xfer_encoding;\n \t}\n \tif (defined $xfer_encoding) {\n \t\tpush @xh, \"Content-Transfer-Encoding: $xfer_encoding\";\n@@ -1852,13 +1851,16 @@ sub apply_transfer_encoding {\n \t$message = MIME::Base64::decode($message)\n \t\tif ($from eq 'base64');\n \n+\t$to = ($message =~ /.{999,}/) ? 'quoted-printable' : '8bit'\n+\t\tif $to eq 'auto';\n+\n \tdie __(\"cannot send message as 7bit\")\n \t\tif ($to eq '7bit' and $message =~ /[^[:ascii:]]/);\n-\treturn $message\n+\treturn ($message, $to)\n \t\tif ($to eq '7bit' or $to eq '8bit');\n-\treturn MIME::QuotedPrint::encode($message, \"\\n\", 0)\n+\treturn (MIME::QuotedPrint::encode($message, \"\\n\", 0), $to)\n \t\tif ($to eq 'quoted-printable');\n-\treturn MIME::Base64::encode($message, \"\\n\")\n+\treturn (MIME::Base64::encode($message, \"\\n\"), $to)\n \t\tif ($to eq 'base64');\n \tdie __(\"invalid transfer encoding\");\n }\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex e80eacbb1b..a35cba6a4c 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -456,6 +456,29 @@ test_expect_success $PREREQ 'allow long lines with --no-validate' '\n \t\t2>errors\n '\n \n+test_expect_success $PREREQ 'short lines with auto encoding are 8bit' '\n+\tclean_fake_sendmail &&\n+\tgit send-email \\\n+\t\t--from=\"A <author@example.com>\" \\\n+\t\t--to=nobody@example.com \\\n+\t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n+\t\t--transfer-encoding=auto \\\n+\t\t$patches &&\n+\tgrep \"Content-Transfer-Encoding: 8bit\" msgtxt1\n+'\n+\n+test_expect_success $PREREQ 'long lines with auto encoding are quoted-printable' '\n+\tclean_fake_sendmail &&\n+\tgit send-email \\\n+\t\t--from=\"Example <nobody@example.com>\" \\\n+\t\t--to=nobody@example.com \\\n+\t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n+\t\t--transfer-encoding=auto \\\n+\t\t--no-validate \\\n+\t\tlongline.patch &&\n+\tgrep \"Content-Transfer-Encoding: quoted-printable\" msgtxt1\n+'\n+\n test_expect_success $PREREQ 'Invalid In-Reply-To' '\n \tclean_fake_sendmail &&\n \tgit send-email \\\n"},{"id":"351897","messageId":"20180708221713.518276-3-sandals@crustytoothpaste.net","threadId":"48832","inReplyTo":"20180708221713.518276-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 2/4] send-email: accept long lines with suitable transfer encoding","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-08T22:17:11Z","receivedAt":"2018-07-08T22:17:31Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"With --validate (which is the default), we warn about lines exceeding\n998 characters due to the limits specified in RFC 5322.  However, if\nwe're using a suitable transfer encoding (quoted-printable or base64),\nwe're guaranteed not to have lines exceeding 76 characters, so there's\nno need to fail in this case.  The auto transfer encoding handles this\nspecific case, so accept it as well.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n Documentation/git-send-email.txt |  7 +++++--\n git-send-email.perl              | 18 +++++++++++-------\n t/t9001-send-email.sh            | 13 +++++++++++++\n 3 files changed, 29 insertions(+), 9 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 385c7de9e2..0e648075bb 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -401,8 +401,11 @@ have been specified, in which case default to 'compose'.\n +\n --\n \t\t*\tInvoke the sendemail-validate hook if present (see linkgit:githooks[5]).\n-\t\t*\tWarn of patches that contain lines longer than 998 characters; this\n-\t\t\tis due to SMTP limits as described by http://www.ietf.org/rfc/rfc2821.txt.\n+\t\t*\tWarn of patches that contain lines longer than\n+\t\t\t998 characters unless a suitable transfer encoding\n+\t\t\t('auto', 'base64', or 'quoted-printable') is used;\n+\t\t\tthis is due to SMTP limits as described by\n+\t\t\thttp://www.ietf.org/rfc/rfc2821.txt.\n --\n +\n Default is the value of `sendemail.validate`; if this is not set,\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex 1736a09d21..e6bcc55827 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -645,7 +645,7 @@ sub is_format_patch_arg {\n if ($validate) {\n \tforeach my $f (@files) {\n \t\tunless (-p $f) {\n-\t\t\tmy $error = validate_patch($f);\n+\t\t\tmy $error = validate_patch($f, $target_xfer_encoding);\n \t\t\t$error and die sprintf(__(\"fatal: %s: %s\\nwarning: no patches were sent\\n\"),\n \t\t\t\t\t\t  $f, $error);\n \t\t}\n@@ -1879,7 +1879,7 @@ sub unique_email_list {\n }\n \n sub validate_patch {\n-\tmy $fn = shift;\n+\tmy ($fn, $xfer_encoding) = @_;\n \n \tif ($repo) {\n \t\tmy $validate_hook = catfile(catdir($repo->repo_path(), 'hooks'),\n@@ -1899,11 +1899,15 @@ sub validate_patch {\n \t\treturn $hook_error if $hook_error;\n \t}\n \n-\topen(my $fh, '<', $fn)\n-\t\tor die sprintf(__(\"unable to open %s: %s\\n\"), $fn, $!);\n-\twhile (my $line = <$fh>) {\n-\t\tif (length($line) > 998) {\n-\t\t\treturn sprintf(__(\"%s: patch contains a line longer than 998 characters\"), $.);\n+\t# Any long lines will be automatically fixed if we use a suitable transfer\n+\t# encoding.\n+\tunless ($xfer_encoding =~ /^(?:auto|quoted-printable|base64)$/) {\n+\t\topen(my $fh, '<', $fn)\n+\t\t\tor die sprintf(__(\"unable to open %s: %s\\n\"), $fn, $!);\n+\t\twhile (my $line = <$fh>) {\n+\t\t\tif (length($line) > 998) {\n+\t\t\t\treturn sprintf(__(\"%s: patch contains a line longer than 998 characters\"), $.);\n+\t\t\t}\n \t\t}\n \t}\n \treturn;\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex a35cba6a4c..1b474cca28 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -479,6 +479,19 @@ test_expect_success $PREREQ 'long lines with auto encoding are quoted-printable'\n \tgrep \"Content-Transfer-Encoding: quoted-printable\" msgtxt1\n '\n \n+for enc in auto quoted-printable base64\n+do\n+\ttest_expect_success $PREREQ \"--validate passes with encoding $enc\" '\n+\t\tgit send-email \\\n+\t\t\t--from=\"Example <nobody@example.com>\" \\\n+\t\t\t--to=nobody@example.com \\\n+\t\t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n+\t\t\t--transfer-encoding=$enc \\\n+\t\t\t--validate \\\n+\t\t\t$patches longline.patch\n+\t'\n+done\n+\n test_expect_success $PREREQ 'Invalid In-Reply-To' '\n \tclean_fake_sendmail &&\n \tgit send-email \\\n"},{"id":"351898","messageId":"20180708221713.518276-5-sandals@crustytoothpaste.net","threadId":"48832","inReplyTo":"20180708221713.518276-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 4/4] docs: correct RFC specifying email line length","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-08T22:17:13Z","receivedAt":"2018-07-08T22:17:34Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"The git send-email documentation specifies RFC 2821 (the SMTP RFC) as\nproviding line length limits, but the specification that restricts line\nlength to 998 octets is RFC 2822 (the email message format RFC).  Since\nRFC 2822 has been obsoleted by RFC 5322, update the text to refer to RFC\n5322 instead of RFC 2821.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n Documentation/git-send-email.txt | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 2f32dbf16d..465a4ecbed 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -404,7 +404,7 @@ have been specified, in which case default to 'compose'.\n \t\t\t998 characters unless a suitable transfer encoding\n \t\t\t('auto', 'base64', or 'quoted-printable') is used;\n \t\t\tthis is due to SMTP limits as described by\n-\t\t\thttp://www.ietf.org/rfc/rfc2821.txt.\n+\t\t\thttp://www.ietf.org/rfc/rfc5322.txt.\n --\n +\n Default is the value of `sendemail.validate`; if this is not set,\n"},{"id":"351899","messageId":"20180708221713.518276-4-sandals@crustytoothpaste.net","threadId":"48832","inReplyTo":"20180708221713.518276-1-sandals@crustytoothpaste.net","subject":"[PATCH v2 3/4] send-email: automatically determine transfer-encoding","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-07-08T22:17:12Z","receivedAt":"2018-07-08T22:17:36Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"git send-email, when invoked without a --transfer-encoding option, sends\n8bit data without a MIME version or a transfer encoding.  This has\nseveral downsides.\n\nFirst, unless the transfer encoding is specified, it defaults to 7bit,\nmeaning that non-ASCII data isn't allowed.  Second, if lines longer than\n998 bytes are used, we will send an message that is invalid according to\nRFC 5322.  The --validate option, which is the default, catches this\nissue, but it isn't clear to many people how to resolve this.\n\nTo solve these issues, default the transfer encoding to \"auto\", so that\nwe explicitly specify 8bit encoding when lines don't exceed 998 bytes\nand quoted-printable otherwise.  This means that we now always emit\nContent-Transfer-Encoding and MIME-Version headers, so remove the\nconditionals from this portion of the code.\n\nIt is unlikely that the unconditional inclusion of these two headers\nwill affect the deliverability of messages in anything but a positive\nway, since MIME is already widespread and well understood by most email\nprograms.\n\nSigned-off-by: brian m. carlson <sandals@crustytoothpaste.net>\n---\n Documentation/git-send-email.txt |  3 +--\n git-send-email.perl              | 18 ++++++------------\n t/t9001-send-email.sh            | 21 +++++++++++++++++++++\n 3 files changed, 28 insertions(+), 14 deletions(-)\n\ndiff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt\nindex 0e648075bb..2f32dbf16d 100644\n--- a/Documentation/git-send-email.txt\n+++ b/Documentation/git-send-email.txt\n@@ -147,8 +147,7 @@ Note that no attempts whatsoever are made to validate the encoding.\n \totherwise.\n +\n Default is the value of the `sendemail.transferEncoding` configuration\n-value; if that is unspecified, git will use 8bit and not add a\n-Content-Transfer-Encoding header.\n+value; if that is unspecified, default to `auto`.\n \n --xmailer::\n --no-xmailer::\ndiff --git a/git-send-email.perl b/git-send-email.perl\nindex e6bcc55827..f4c07908d2 100755\n--- a/git-send-email.perl\n+++ b/git-send-email.perl\n@@ -231,7 +231,7 @@ sub do_edit {\n my (@suppress_cc);\n my ($auto_8bit_encoding);\n my ($compose_encoding);\n-my ($target_xfer_encoding);\n+my $target_xfer_encoding = 'auto';\n \n my ($debug_net_smtp) = 0;\t\t# Net::SMTP, see send_message()\n \n@@ -1737,17 +1737,11 @@ sub process_file {\n \t\t\t}\n \t\t}\n \t}\n-\tif (defined $target_xfer_encoding) {\n-\t\t$xfer_encoding = '8bit' if not defined $xfer_encoding;\n-\t\t($message, $xfer_encoding) = apply_transfer_encoding(\n-\t\t\t$message, $xfer_encoding, $target_xfer_encoding);\n-\t}\n-\tif (defined $xfer_encoding) {\n-\t\tpush @xh, \"Content-Transfer-Encoding: $xfer_encoding\";\n-\t}\n-\tif (defined $xfer_encoding or $has_content_type) {\n-\t\tunshift @xh, 'MIME-Version: 1.0' unless $has_mime_version;\n-\t}\n+\t$xfer_encoding = '8bit' if not defined $xfer_encoding;\n+\t($message, $xfer_encoding) = apply_transfer_encoding(\n+\t\t$message, $xfer_encoding, $target_xfer_encoding);\n+\tpush @xh, \"Content-Transfer-Encoding: $xfer_encoding\";\n+\tunshift @xh, 'MIME-Version: 1.0' unless $has_mime_version;\n \n \t$needs_confirm = (\n \t\t$confirm eq \"always\" or\ndiff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh\nindex 1b474cca28..1da282c415 100755\n--- a/t/t9001-send-email.sh\n+++ b/t/t9001-send-email.sh\n@@ -225,6 +225,8 @@ X-Mailer: X-MAILER-STRING\n In-Reply-To: <unique-message-id@example.com>\n References: <unique-message-id@example.com>\n Reply-To: Reply <reply@example.com>\n+MIME-Version: 1.0\n+Content-Transfer-Encoding: 8bit\n \n Result: OK\n EOF\n@@ -415,6 +417,7 @@ test_expect_success $PREREQ 'reject long lines' '\n \t\t--from=\"Example <nobody@example.com>\" \\\n \t\t--to=nobody@example.com \\\n \t\t--smtp-server=\"$(pwd)/fake.sendmail\" \\\n+\t\t--transfer-encoding=8bit \\\n \t\t$patches longline.patch \\\n \t\t2>errors &&\n \tgrep longline.patch errors\n@@ -609,6 +612,8 @@ Subject: [PATCH 1/1] Second.\n Date: DATE-STRING\n Message-Id: MESSAGE-ID-STRING\n X-Mailer: X-MAILER-STRING\n+MIME-Version: 1.0\n+Content-Transfer-Encoding: 8bit\n \n Result: OK\n EOF\n@@ -653,6 +658,8 @@ Subject: [PATCH 1/1] Second.\n Date: DATE-STRING\n Message-Id: MESSAGE-ID-STRING\n X-Mailer: X-MAILER-STRING\n+MIME-Version: 1.0\n+Content-Transfer-Encoding: 8bit\n \n Result: OK\n EOF\n@@ -688,6 +695,8 @@ Subject: [PATCH 1/1] Second.\n Date: DATE-STRING\n Message-Id: MESSAGE-ID-STRING\n X-Mailer: X-MAILER-STRING\n+MIME-Version: 1.0\n+Content-Transfer-Encoding: 8bit\n \n Result: OK\n EOF\n@@ -714,6 +723,8 @@ Subject: [PATCH 1/1] Second.\n Date: DATE-STRING\n Message-Id: MESSAGE-ID-STRING\n X-Mailer: X-MAILER-STRING\n+MIME-Version: 1.0\n+Content-Transfer-Encoding: 8bit\n \n Result: OK\n EOF\n@@ -748,6 +759,8 @@ Subject: [PATCH 1/1] Second.\n Date: DATE-STRING\n Message-Id: MESSAGE-ID-STRING\n X-Mailer: X-MAILER-STRING\n+MIME-Version: 1.0\n+Content-Transfer-Encoding: 8bit\n \n Result: OK\n EOF\n@@ -779,6 +792,8 @@ Subject: [PATCH 1/1] Second.\n Date: DATE-STRING\n Message-Id: MESSAGE-ID-STRING\n X-Mailer: X-MAILER-STRING\n+MIME-Version: 1.0\n+Content-Transfer-Encoding: 8bit\n \n Result: OK\n EOF\n@@ -810,6 +825,8 @@ Subject: [PATCH 1/1] Second.\n Date: DATE-STRING\n Message-Id: MESSAGE-ID-STRING\n X-Mailer: X-MAILER-STRING\n+MIME-Version: 1.0\n+Content-Transfer-Encoding: 8bit\n \n Result: OK\n EOF\n@@ -845,6 +862,8 @@ Subject: [PATCH 1/1] Second.\n Date: DATE-STRING\n Message-Id: MESSAGE-ID-STRING\n X-Mailer: X-MAILER-STRING\n+MIME-Version: 1.0\n+Content-Transfer-Encoding: 8bit\n \n Result: OK\n EOF\n@@ -873,6 +892,8 @@ Subject: [PATCH 1/1] Second.\n Date: DATE-STRING\n Message-Id: MESSAGE-ID-STRING\n X-Mailer: X-MAILER-STRING\n+MIME-Version: 1.0\n+Content-Transfer-Encoding: 8bit\n \n Result: OK\n EOF\n"},{"id":"351900","messageId":"20180708222254.GA10282@homura.localdomain","threadId":"48832","inReplyTo":"20180708221713.518276-1-sandals@crustytoothpaste.net","subject":"Re: [PATCH v2 0/4] Automatic transfer encoding for patches","fromName":"Drew DeVault","fromEmail":"sir@cmpwn.com","sentAt":"2018-07-08T22:22:54Z","receivedAt":"2018-07-08T22:23:00Z","isPatch":true,"sender":{"key":"sir@cmpwn.com","avatar":"https://avatars.githubusercontent.com/u/1310872?v=4"},"body":"LGTM, thanks for the v2.\n"}]}