Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed a unicode encoding bug in the contact form.

Also removed duplicated code.
  • Loading branch information...
commit 62dce2424108b906c3dfafa748632338dd111ac5 1 parent ec6949e
Jacob Kaplan-Moss authored
5  contact/forms.py
@@ -10,7 +10,7 @@ def subject(self):
10 10
         return "[Contact form] " + self.cleaned_data["message_subject"]
11 11
 
12 12
     def message(self):
13  
-        return "From: %(name)s <%(email)s>\n\n%(body)s" % self.cleaned_data
  13
+        return u"From: {name} <{email}>\n\n{body}".format(**self.cleaned_data)
14 14
 
15 15
 class FoundationContactForm(BaseContactForm):
16 16
     recipient_list = ["dsf-board@googlegroups.com"]
@@ -27,6 +27,3 @@ def __init__(self, *args, **kwargs):
27 27
 
28 28
     def subject(self):
29 29
         return "Django Code of Conduct feedback"
30  
-
31  
-    def message(self):
32  
-        return "From: {name} <{email}>\n\n{body}".format(**self.cleaned_data)
9  contact/tests.py
@@ -24,3 +24,12 @@ def test_coc_contact(self):
24 24
         resp = self.client.post('/contact/code-of-conduct/', data)
25 25
         self.assertRedirects(resp, '/conduct/')
26 26
         self.assertEqual(mail.outbox[-1].subject, 'Django Code of Conduct feedback')
  27
+
  28
+    def test_coc_contact_unicode(self):
  29
+        data = {
  30
+            'name': 'A. Random Hacker',
  31
+            'email': 'a.random@example.com',
  32
+            'body': u'Hello, \u2603!'
  33
+        }
  34
+        resp = self.client.post('/contact/code-of-conduct/', data)
  35
+        self.assertRedirects(resp, '/conduct/')

0 notes on commit 62dce24

Please sign in to comment.
Something went wrong with that request. Please try again.