Commit fdb77357 authored by Arkadiusz Hiler's avatar Arkadiusz Hiler

Switch to base64 for mails over 200 chars in line

This is done because Python's qp encoding can be a bit problematic with
line endings.

Also, bumping the line length limit to 200 makes the downloaded mboxes
readable with any sensible patches and is well below the RFC 5322 limit
of 998 characters.

The changes in checksums are due to emails not being qp-encoded.
Signed-off-by: default avatarArkadiusz Hiler <arkadiusz.hiler@intel.com>
parent 257b5809
......@@ -389,14 +389,14 @@ class MboxEncoding(TestCase):
self.person = defaults.patch_author_person
self.person.save()
def testQuotedPrintableIfLineOver78(self):
patch = self.create_patch("x", "y" * 79)
def testBase64IfLineOver200(self):
patch = self.create_patch("x", "y" * 201)
response = self.client.get('/patch/%d/mbox/' % patch.id)
self.assertContains(response,
'Content-Transfer-Encoding: quoted-printable')
'Content-Transfer-Encoding: base64')
def test7bitIfLine78orLess(self):
patch = self.create_patch("x", "y" * 78)
def test7bitIfLine200orLess(self):
patch = self.create_patch("x", "y" * 200)
response = self.client.get('/patch/%d/mbox/' % patch.id)
self.assertContains(response,
'Content-Transfer-Encoding: 7bit')
......
......@@ -249,23 +249,21 @@ class APITest(APITestBase):
i += 1
def testSeriesMbox(self):
# XXX: since Python 3 email module wrap header lines differently
self.check_mbox("/series/%s/revisions/1/mbox/" % self.series.pk,
'for_each_-intel_-crtc-v2.mbox',
'db5b40c95b673ce38102943eaa02de69')
'6d59b59dbf751064408249e18401275f')
def testMboxWithCoverLetter(self):
# XXX: since Python 3 email module wrap header lines differently
self.check_mbox("/series/%s/revisions/1/mbox_with_cover/" %
self.series.pk,
'for_each_-intel_-crtc-v2.mbox',
'dd990d02f7d744a0b3b067f1afa831a6')
'826f03a224083df013a2b373459527a3')
def testCoverLetterMbox(self):
self.check_mbox("/series/%s/revisions/1/cover/" %
self.series.pk,
'for_each_-intel_-crtc-v2.mbox',
'b8cc8c1d04434cb12110e2562a963de9')
'462a3414aedd2710d3dfed8a651ecd10')
def testMboxAndMboxWithCoverShouldBeIdenticalForSeriesWithNoCL(self):
mbox = self.client.get('/api/1.0' +
......
......@@ -21,7 +21,7 @@ from __future__ import absolute_import
import datetime
import time
from email.encoders import encode_7or8bit, encode_quopri
from email.encoders import encode_7or8bit, encode_base64
from email.header import Header
from email.mime.nonmultipart import MIMENonMultipart
from email.parser import HeaderParser
......@@ -185,8 +185,8 @@ class PatchMbox(MIMENonMultipart):
**{'charset': self.patch_charset})
self.set_payload(_text.encode(self.patch_charset))
if max((len(line) for line in _text.splitlines()), default=0) > 78:
encode_quopri(self)
if max((len(line) for line in _text.splitlines()), default=0) > 200:
encode_base64(self)
else:
encode_7or8bit(self)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment