mdelagra avatar mdelagra committed 0603a67

legitimately encoded special characters were being stripped from reviews

Comments (0)

Files changed (2)

mercurial_reviewboard/reviewboard.py

 
         content_type = "multipart/form-data; boundary=%s" % BOUNDARY
 
-        return content_type, unicode(content, errors='ignore')
+        return content_type, content
+
 
 class ApiClient:
     def __init__(self, httpclient):

mercurial_reviewboard/tests/test_reviewboard_api.py

+# coding=UTF8
+from mercurial_reviewboard import reviewboard
+
+
+SAMPLE_DIFF='''diff -r 000000000000 -r 95a59137df3f file_with_special_char.txt
+--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
++++ b/file_with_special_char.txt	Thu Feb 03 15:38:42 2011 -0600
+@@ -0,0 +1,1 @@
++Look it up in the encyclopædia.
+\ No newline at end of file
+'''
+
+
+def test_utf8_files():
+    files = {'path': {'content': SAMPLE_DIFF, 'filename': 'diff'}}
+    client = reviewboard.HttpClient('http://example.org')
+    content_type, content = client._encode_multipart_formdata({}, files)
+    expected_substring = u'Look it up in the encyclop\xe6dia.'
+
+    unicode_content = content.decode('utf-8')
+
+    assert unicode_content.index(expected_substring)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.