fix: _sanitize_export_filename crashes on a non-string session name (#1607)

This commit is contained in:
Afonso Coutinho
2026-06-03 00:35:47 +01:00
committed by GitHub
parent 382d49d887
commit 6df0f5e6df
2 changed files with 16 additions and 1 deletions

View File

@@ -0,0 +1,15 @@
"""Regression: _sanitize_export_filename must tolerate a non-string name.
It did `name = name or ""` then `re.sub(..., name)`. A non-string name (e.g. an
int session name) is truthy, so re.sub raised TypeError. Coerce non-strings.
"""
from routes.session_routes import _sanitize_export_filename
def test_non_string_name_does_not_crash():
assert _sanitize_export_filename(12345) == ""
assert _sanitize_export_filename(None) == ""
def test_valid_name_sanitized():
assert _sanitize_export_filename("a/b?c.txt") == "a_b_c.txt"