aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTom Christie2014-12-05 12:35:24 +0000
committerTom Christie2014-12-05 12:35:24 +0000
commitde4ef6e3945e1281e0145d7ca19b6213f2aebfc6 (patch)
tree065407b1b7e444ea37ba9d18e72045fdc99cb871 /tests
parente2b39088345e564a06ce332b740215600c29e481 (diff)
parent23fa6e54ce978055f7d4af5f5f99bc6f419f990b (diff)
downloaddjango-rest-framework-de4ef6e3945e1281e0145d7ca19b6213f2aebfc6.tar.bz2
Merge pull request #2195 from tomchristie/tomchristie-escape-u2028-u2029-json
Escape \u2028 and \u2029 in JSON output.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_renderers.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/test_renderers.py b/tests/test_renderers.py
index 416d7f22..61dd7c7a 100644
--- a/tests/test_renderers.py
+++ b/tests/test_renderers.py
@@ -384,6 +384,15 @@ class UnicodeJSONRendererTests(TestCase):
content = renderer.render(obj, 'application/json')
self.assertEqual(content, '{"countries":["United Kingdom","France","EspaƱa"]}'.encode('utf-8'))
+ def test_u2028_u2029(self):
+ # The \u2028 and \u2029 characters should be escaped,
+ # even when the non-escaping unicode representation is used.
+ # Regression test for #2169
+ obj = {'should_escape': '\u2028\u2029'}
+ renderer = JSONRenderer()
+ content = renderer.render(obj, 'application/json')
+ self.assertEqual(content, '{"should_escape":"\\u2028\\u2029"}'.encode('utf-8'))
+
class AsciiJSONRendererTests(TestCase):
"""