Skip to content
Myr

tojson no longer escapes script blocks in HTML5 parsers. Fixed #605

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 01ac057 · Browse files · 3 files+10 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+10 added−5 removed

  • other:+10 added−5 removed

3 files+10 added−5 removed

modified:flask/testsuite/helpers.py+2 added
95 unmodified lines
96 rv = render('{{ "</script>"|tojson|safe }}')97 self.assert_equal(rv, '"<\\/script>"')98 rv = render('{{ "<\0/script>"|tojson|safe }}')99 self.assert_equal(rv, '"<\\u0000\\/script>"')100 rv = render('{{ "<!--<script>"|tojson|safe }}')101 self.assert_equal(rv, '"<\\u0021--<script>"')102103 def test_modified_url_encoding(self):104 class ModifiedRequest(flask.Request):105 url_charset = 'euc-kr'
363 unmodified lines
modified:flask/helpers.py+7 added-5 removed
43 unmodified lines
444546# figure out if simplejson escapes slashes. This behavior was changed47# from one version to another without reason.48if '\\/' not in json.dumps('/'):49 def _tojson_filter(*args, **kwargs):50 return json.dumps(*args, **kwargs).replace('/', '\\/')51else:52 _tojson_filter = json.dumps48_slash_escape = '\\/' not in json.dumps('/')4950def _tojson_filter(*args, **kwargs):51 rv = json.dumps(*args, **kwargs)52 if _slash_escape:53 rv = rv.replace('/', '\\/')54 return rv.replace('<!', '<\\u0021')555657# sentinel58_missing = object()5960
815 unmodified lines
modified:CHANGES+1 added
12 unmodified lines
13 :ref:`upgrading-to-010` for more information.14- Added ``template_test`` methods in addition to the already existing15 ``template_filter`` method family.16- Set the content-length header for x-sendfile.17- ``tojson`` filter now does not escape script blocks in HTML5 parsers.1819Version 0.920-----------21
365 unmodified lines