summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2008-10-09 22:50:49 +1100
committerJeremy Kerr <jk@ozlabs.org>2008-10-09 22:50:49 +1100
commit94ae2713d4aca80b7dc1168a60f98bbe38d86e12 (patch)
tree3cb6702ba2b39a2e9a0a92208bf695d73bdfd0ca
parent4a039197705f92ee1c362401a7f7bb834ecc9079 (diff)
downloadpatchwork-94ae2713d4aca80b7dc1168a60f98bbe38d86e12.tar.bz2
patchwork-94ae2713d4aca80b7dc1168a60f98bbe38d86e12.tar.xz
[models] Fix exception on mbox view with non-ascii submitter name
We need to unicode the name instead of str-ing it. Add test. Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
-rw-r--r--apps/patchwork/models.py2
-rw-r--r--apps/patchwork/tests/encodings.py25
2 files changed, 25 insertions, 2 deletions
diff --git a/apps/patchwork/models.py b/apps/patchwork/models.py
index 02fb8b4..1da1d99 100644
--- a/apps/patchwork/models.py
+++ b/apps/patchwork/models.py
@@ -252,7 +252,7 @@ class Patch(models.Model):
mail['Subject'] = self.name
mail['Date'] = email.utils.formatdate(
time.mktime(self.date.utctimetuple()))
- mail['From'] = str(self.submitter)
+ mail['From'] = unicode(self.submitter)
mail['X-Patchwork-Id'] = str(self.id)
mail.set_unixfrom('From patchwork ' + self.date.ctime())
diff --git a/apps/patchwork/tests/encodings.py b/apps/patchwork/tests/encodings.py
index 9dde023..397b39b 100644
--- a/apps/patchwork/tests/encodings.py
+++ b/apps/patchwork/tests/encodings.py
@@ -20,7 +20,7 @@
import unittest
import os
import time
-from patchwork.models import Patch
+from patchwork.models import Patch, Person
from patchwork.tests.utils import defaults, read_patch
from django.test import TestCase
from django.test.client import Client
@@ -62,3 +62,26 @@ class UTF8PatchViewTest(TestCase):
defaults.patch_author_person.delete()
defaults.project.delete()
+class UTF8HeaderPatchViewTest(UTF8PatchViewTest):
+ patch_filename = '0002-utf-8.patch'
+ patch_encoding = 'utf-8'
+ patch_author_name = u'P\xe4tch Author'
+
+ def setUp(self):
+ defaults.project.save()
+ self.patch_author = Person(name = self.patch_author_name,
+ email = defaults.patch_author_person.email)
+ self.patch_author.save()
+ self.patch_content = read_patch(self.patch_filename,
+ encoding = self.patch_encoding)
+ self.patch = Patch(project = defaults.project,
+ msgid = 'x', name = defaults.patch_name,
+ submitter = self.patch_author,
+ content = self.patch_content)
+ self.patch.save()
+ self.client = Client()
+
+ def tearDown(self):
+ self.patch.delete()
+ self.patch_author.delete()
+ defaults.project.delete()