Skip to content

Commit c313f2e

Browse files
committed
escape quotes
1 parent 131f2e2 commit c313f2e

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "simple-html"
3-
version = "1.1.0"
3+
version = "1.1.1"
44
readme = "README.md"
55
description = "Template-less html rendering in Python"
66
authors = ["Keith Philpott <[email protected]>"]

simple_html/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def __hash__(self) -> int:
8080

8181
def escape_attribute_key(k: str) -> str:
8282
return (
83-
escape(k)
83+
escape(k, True)
8484
.replace("=", "&#x3D;")
8585
.replace("\\", "&#x5C;")
8686
.replace("`", "&#x60;")
@@ -121,7 +121,7 @@ def __call__(
121121
else escape_attribute_key(key)
122122
)
123123
if isinstance(val, str):
124-
attrs += f' {key}="{escape(val)}"'
124+
attrs += f' {key}="{escape(val, True)}"'
125125
elif isinstance(val, SafeString):
126126
attrs += f' {key}="{val.safe_str}"'
127127
elif val is None:

tests/test_simple_html.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ def test_render_with_escaped_attributes() -> None:
186186
== '<div onmousenter&#x3D;&quot;alert(1)&quot;&nbsp;noop="1"></div>'
187187
)
188188
assert (
189-
render(span({"<script></script>": ">"}))
190-
== '<span &lt;script&gt;&lt;/script&gt;="&gt;"></span>'
189+
render(span({"<script>\"</script>": "\">"}))
190+
== '<span &lt;script&gt;&quot;&lt;/script&gt;="&quot;&gt;"></span>'
191191
)
192192
# vals and keys escape slightly differently
193193
assert (

0 commit comments

Comments
 (0)