Add tests for svg escaping

This commit is contained in:
Jonah Lawrence 2022-10-07 16:01:30 +00:00 committed by GitHub
parent f87623f8d7
commit 1a8ddbdac6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View file

@ -0,0 +1 @@
<svg height='50' width='200'><text x='0' y='25'>{{ text }}</text></svg>

After

Width:  |  Height:  |  Size: 71 B

View file

@ -114,6 +114,15 @@ def test_escaping_without_template_filename(app, client, req_ctx):
assert flask.render_template("mail.txt", foo="<test>") == "<test> Mail"
def test_escaping_svg(app, client):
@app.route("/")
def index():
return flask.render_template("escaping_template.svg", text="<test>")
rv = client.get("/")
assert rv.data == b"<svg height='50' width='200'><text x='0' y='25'>&lt;test&gt;</text></svg>"
def test_macros(app, req_ctx):
macro = flask.get_template_attribute("_macro.html", "hello")
assert macro("World") == "Hello World!"