Ensure that angle brackets in pyscript tag are escaped before parsing (#684)

* Ensure that angle brackets in pyscript tag are escaped before parsing

* Improve tests

* Update pyscriptjs/tests/test_01_basic.py

Co-authored-by: James A. Bednar <jbednar@users.noreply.github.com>

Co-authored-by: James A. Bednar <jbednar@users.noreply.github.com>
This commit is contained in:
Philipp Rudiger
2022-08-16 18:11:09 +02:00
committed by GitHub
parent 410ddf314c
commit 8275aa2810
2 changed files with 20 additions and 1 deletions

View File

@@ -36,3 +36,18 @@ class TestBasic(PyScriptTest):
"""
)
assert self.console.info.lines == ["one", "two", "three", "four"]
def test_escaping_of_angle_brackets(self):
"""
Check that py-script tags escape angle brackets
"""
# NOTE: this test relies on the fact that pyscript does not write
# anything to console.info. If we start writing to info in the future,
# we will probably need to tweak this test.
self.pyscript_run(
"""
<py-script>import js; js.console.info(1<2, 1>2)</py-script>
<py-script>js.console.info("<div></div>")</py-script>
"""
)
assert self.console.info.lines == ["true false", "<div></div>"]