]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
views: Don't munge the 'From' field of patches v1.1.3
authorDoug Anderson <dianders@chromium.org>
Sat, 19 Nov 2016 19:32:09 +0000 (19:32 +0000)
committerStephen Finucane <stephen@that.guru>
Tue, 31 Jan 2017 19:57:36 +0000 (19:57 +0000)
At the moment patchwork always uses the official submitter name (as
patchwork understands it) as the "From" for patches that you receive.
This isn't quite what users expect and has some unfortunate
consequences.

The biggest problem is that patchwork saves the "official" name for an
email address the first time it sees an email from them.  If that name
is wrong (or was missing) patchwork will be confused even if future
emails from this person are fixed.  There are similar problems if a
user changes his/her name (get married?).

It seems better to just have each patch report the actual "From" that
was used to send that patch.  We'll still return the submitter in
'X-Patchwork-Submitter' just in case someone wants it.

Conflicts:
patchwork/tests/test_mboxviews.py

Reported-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Stephen Finucane <stephen@that.guru>
(cherry picked from commit d365402fb98dfb2c4aea4b58346096f85bdfa0c3)

patchwork/tests/test_mboxviews.py
patchwork/views/__init__.py

index a2bee0d1e8729b7383c41f11c5e4fb58cfbc77da..5e98457e2f85b23b77dfa5aab670d7953ea1e68a 100644 (file)
@@ -107,6 +107,7 @@ class MboxPassThroughHeaderTest(TestCase):
         self.cc_header = 'Cc: CC Person <cc@example.com>'
         self.to_header = 'To: To Person <to@example.com>'
         self.date_header = 'Date: Fri, 7 Jun 2013 15:42:54 +1000'
+        self.from_header = 'From: John Doe <john@doe.com>'
 
         self.patch = Patch(project=defaults.project,
                            msgid='p1', name='testpatch',
@@ -133,6 +134,13 @@ class MboxPassThroughHeaderTest(TestCase):
         response = self.client.get('/patch/%d/mbox/' % self.patch.id)
         self.assertContains(response, self.date_header)
 
+    def testFromHeader(self):
+        self.patch.headers = self.from_header = '\n'
+        self.patch.save()
+
+        response = self.client.get('/patch/%d/mbox/' % self.patch.id)
+        self.assertContains(response, self.from_header)
+
 
 class MboxGeneratedHeaderTest(TestCase):
     fixtures = ['default_states']
@@ -161,6 +169,10 @@ class MboxGeneratedHeaderTest(TestCase):
         self.assertContains(response,
                             'X-Patchwork-Delegate: %s' % self.user.email)
 
+    def testPatchworkFromHeader(self):
+        response = self.client.get('/patch/%d/mbox/' % self.patch.id)
+        self.assertContains(response, 'X-Patchwork-Submitter:')
+
 
 class MboxBrokenFromHeaderTest(TestCase):
     fixtures = ['default_states']
index ae0d561d690f0a02f76575ed5ad2afe249ad961f..a38da9d33971e7e013cebb7393df03b23e1d61b6 100644 (file)
@@ -353,7 +353,7 @@ def patch_to_mbox(patch):
 
     mail = PatchMbox(body)
     mail['Subject'] = patch.name
-    mail['From'] = email.utils.formataddr((
+    mail['X-Patchwork-Submitter'] = email.utils.formataddr((
         str(Header(patch.submitter.name, mail.patch_charset)),
         patch.submitter.email))
     mail['X-Patchwork-Id'] = str(patch.id)
@@ -362,7 +362,7 @@ def patch_to_mbox(patch):
     mail['Message-Id'] = patch.msgid
     mail.set_unixfrom('From patchwork ' + patch.date.ctime())
 
-    copied_headers = ['To', 'Cc', 'Date']
+    copied_headers = ['To', 'Cc', 'Date', 'From']
     orig_headers = HeaderParser().parsestr(str(patch.headers))
     for header in copied_headers:
         if header in orig_headers: