forked from orbit-oss/flask
Enable autoescape for render_template_string
This commit is contained in:
parent
e4f635f8d7
commit
99c99c4c16
7 changed files with 41 additions and 5 deletions
|
|
@ -81,10 +81,29 @@ def test_escaping():
|
|||
]
|
||||
|
||||
def test_no_escaping():
|
||||
text = '<p>Hello World!'
|
||||
app = flask.Flask(__name__)
|
||||
@app.route('/')
|
||||
def index():
|
||||
return flask.render_template('non_escaping_template.txt', text=text,
|
||||
html=flask.Markup(text))
|
||||
lines = app.test_client().get('/').data.splitlines()
|
||||
assert lines == [
|
||||
b'<p>Hello World!',
|
||||
b'<p>Hello World!',
|
||||
b'<p>Hello World!',
|
||||
b'<p>Hello World!',
|
||||
b'<p>Hello World!',
|
||||
b'<p>Hello World!',
|
||||
b'<p>Hello World!',
|
||||
b'<p>Hello World!'
|
||||
]
|
||||
|
||||
def test_escaping_without_template_filename():
|
||||
app = flask.Flask(__name__)
|
||||
with app.test_request_context():
|
||||
assert flask.render_template_string(
|
||||
'{{ foo }}', foo='<test>') == '<test>'
|
||||
'{{ foo }}', foo='<test>') == '<test>'
|
||||
assert flask.render_template('mail.txt', foo='<test>') == \
|
||||
'<test> Mail'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue