Fixed XSS problem by escaping all slashes in JSON.

This also probes simplejson first to figure out if it escapes slashes
which it did in earlier versions.
This commit is contained in:
Armin Ronacher 2010-04-20 15:12:16 +02:00
parent 268302fc68
commit 9f6bc93e4d
2 changed files with 13 additions and 1 deletions

View file

@ -245,6 +245,8 @@ class JSONTestCase(unittest.TestCase):
with app.test_request_context():
rv = flask.render_template_string('{{ "</script>"|tojson|safe }}')
assert rv == '"<\\/script>"'
rv = flask.render_template_string('{{ "<\0/script>"|tojson|safe }}')
assert rv == '"<\\u0000\\/script>"'
class TemplatingTestCase(unittest.TestCase):