aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTom Christie2014-12-03 22:33:34 +0000
committerTom Christie2014-12-03 22:33:34 +0000
commit23fa6e54ce978055f7d4af5f5f99bc6f419f990b (patch)
treed7b9596a2d242625768da599f294dec2471a1e06 /tests
parent71a8cb2282d2cb5cb92e74975f762bbdf8ff0d69 (diff)
downloaddjango-rest-framework-23fa6e54ce978055f7d4af5f5f99bc6f419f990b.tar.bz2
Escape \u2028 and \u2029 in JSON output.
Closes #2169.
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):
"""