Skip to content

Commit 4d59fe5

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent f7e1c4e commit 4d59fe5

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

tests/_server/templates/test_templates.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,9 @@ def test_static_files_injection_prevention(self) -> None:
737737

738738
def test_static_malicious_filename_injection(self) -> None:
739739
"""Test that malicious filenames in static exports are properly escaped."""
740-
malicious_filepath = self.tmp_path / "</script><script>alert(1)</script>.py"
740+
malicious_filepath = (
741+
self.tmp_path / "</script><script>alert(1)</script>.py"
742+
)
741743

742744
result = templates.static_notebook_template(
743745
self.html,
@@ -755,7 +757,9 @@ def test_static_malicious_filename_injection(self) -> None:
755757

756758
# Must not contain unescaped script tags
757759
assert "</script><script>" not in result
758-
assert "<script>alert(1)" not in result.replace("\\u003Cscript\\u003E", "")
760+
assert "<script>alert(1)" not in result.replace(
761+
"\\u003Cscript\\u003E", ""
762+
)
759763

760764
# Must contain escaped versions in JSON context
761765
assert "\\u003C" in result or "\\u003E" in result

tests/_server/test_templates_filename.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@ def test_script_breakout_prevention(self, payload: str) -> None:
124124
# Must contain escaped versions of dangerous chars
125125
# json_script escapes <, >, & to \uXXXX format
126126
if "<" in payload or ">" in payload or "&" in payload:
127-
assert "\\u003C" in result or "\\u003E" in result or "\\u0026" in result
127+
assert (
128+
"\\u003C" in result
129+
or "\\u003E" in result
130+
or "\\u0026" in result
131+
)
128132

129133
# Must be valid JSON that round-trips correctly
130134
parsed = json.loads(result)
@@ -181,9 +185,9 @@ def test_complex_structure_escaping(
181185
# Combining characters
182186
{"text": "e\u0301"}, # é as combining character
183187
# Right-to-left marks
184-
{"text": "\u200F"},
188+
{"text": "\u200f"},
185189
# Zero-width characters
186-
{"text": "test\u200Bword"},
190+
{"text": "test\u200bword"},
187191
],
188192
)
189193
def test_unicode_handling(self, data: dict) -> None:

0 commit comments

Comments
 (0)