Skip to content

Commit 48c0e00

Browse files
diandersstephenfin
authored andcommitted
views: Don't munge the 'From' field of patches
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 <[email protected]> Signed-off-by: Doug Anderson <[email protected]> Signed-off-by: Stephen Finucane <[email protected]> (cherry picked from commit d365402)
1 parent db885f9 commit 48c0e00

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

patchwork/tests/test_mboxviews.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def setUp(self):
107107
self.cc_header = 'Cc: CC Person <[email protected]>'
108108
self.to_header = 'To: To Person <[email protected]>'
109109
self.date_header = 'Date: Fri, 7 Jun 2013 15:42:54 +1000'
110+
self.from_header = 'From: John Doe <[email protected]>'
110111

111112
self.patch = Patch(project=defaults.project,
112113
msgid='p1', name='testpatch',
@@ -133,6 +134,13 @@ def testDateHeader(self):
133134
response = self.client.get('/patch/%d/mbox/' % self.patch.id)
134135
self.assertContains(response, self.date_header)
135136

137+
def testFromHeader(self):
138+
self.patch.headers = self.from_header = '\n'
139+
self.patch.save()
140+
141+
response = self.client.get('/patch/%d/mbox/' % self.patch.id)
142+
self.assertContains(response, self.from_header)
143+
136144

137145
class MboxGeneratedHeaderTest(TestCase):
138146
fixtures = ['default_states']
@@ -161,6 +169,10 @@ def testPatchworkDelegateHeader(self):
161169
self.assertContains(response,
162170
'X-Patchwork-Delegate: %s' % self.user.email)
163171

172+
def testPatchworkFromHeader(self):
173+
response = self.client.get('/patch/%d/mbox/' % self.patch.id)
174+
self.assertContains(response, 'X-Patchwork-Submitter:')
175+
164176

165177
class MboxBrokenFromHeaderTest(TestCase):
166178
fixtures = ['default_states']

patchwork/views/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ def patch_to_mbox(patch):
353353

354354
mail = PatchMbox(body)
355355
mail['Subject'] = patch.name
356-
mail['From'] = email.utils.formataddr((
356+
mail['X-Patchwork-Submitter'] = email.utils.formataddr((
357357
str(Header(patch.submitter.name, mail.patch_charset)),
358358
patch.submitter.email))
359359
mail['X-Patchwork-Id'] = str(patch.id)
@@ -362,7 +362,7 @@ def patch_to_mbox(patch):
362362
mail['Message-Id'] = patch.msgid
363363
mail.set_unixfrom('From patchwork ' + patch.date.ctime())
364364

365-
copied_headers = ['To', 'Cc', 'Date']
365+
copied_headers = ['To', 'Cc', 'Date', 'From']
366366
orig_headers = HeaderParser().parsestr(str(patch.headers))
367367
for header in copied_headers:
368368
if header in orig_headers:

0 commit comments

Comments
 (0)