launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #26474
[Merge] ~cjwatson/launchpad:py3-codeofconduct-charset into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:py3-codeofconduct-charset into launchpad:master.
Commit message:
Add charset="utf-8" to Content-Type for codes of conduct
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/398896
This is otherwise harmless, and avoids a test failure on Python 3.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-codeofconduct-charset into launchpad:master.
diff --git a/lib/lp/registry/browser/codeofconduct.py b/lib/lp/registry/browser/codeofconduct.py
index 616a11e..892c7fc 100644
--- a/lib/lp/registry/browser/codeofconduct.py
+++ b/lib/lp/registry/browser/codeofconduct.py
@@ -140,7 +140,7 @@ class CodeOfConductDownloadView(DataDownloadView):
causing browsers to download rather than display it.
"""
- content_type = 'text/plain'
+ content_type = 'text/plain;charset="utf-8"'
def getBody(self):
# Use the context attribute 'content' as data to return.
diff --git a/lib/lp/registry/browser/tests/test_codeofconduct.py b/lib/lp/registry/browser/tests/test_codeofconduct.py
index 650ade3..fb2cc0a 100644
--- a/lib/lp/registry/browser/tests/test_codeofconduct.py
+++ b/lib/lp/registry/browser/tests/test_codeofconduct.py
@@ -7,6 +7,7 @@ from __future__ import absolute_import, print_function, unicode_literals
__metaclass__ = type
+from testtools.matchers import MatchesRegex
from zope.component import getUtility
from lp.registry.interfaces.codeofconduct import (
@@ -169,4 +170,6 @@ class TestCodeOfConductBrowser(BrowserTestCase):
self.assertEqual(str(len(content)), browser.headers['Content-length'])
disposition = 'attachment; filename="UbuntuCodeofConduct-2.0.txt"'
self.assertEqual(disposition, browser.headers['Content-disposition'])
- self.assertEqual('text/plain', browser.headers['Content-type'])
+ self.assertThat(
+ browser.headers['Content-type'],
+ MatchesRegex(r'^text/plain;charset="?utf-8"?$'))