mirror of
https://github.com/d9pouces/id_configurator.git
synced 2026-11-09 01:47:21 +01:00
feat: enhance filename sanitization to replace non-identifier characters
Signed-off-by: d9pouces <github@19pouces.net>
This commit is contained in:
@@ -29,8 +29,25 @@ def test_sanitize_filename_leaves_plain_names_untouched() -> None:
|
||||
|
||||
|
||||
def test_sanitize_filename_replaces_forward_slash() -> None:
|
||||
assert sanitize_filename("../../etc/passwd") == ".._.._etc_passwd"
|
||||
assert sanitize_filename("../../etc/passwd") == "______etc_passwd"
|
||||
|
||||
|
||||
def test_sanitize_filename_replaces_backslash() -> None:
|
||||
assert sanitize_filename(r"a\b") == "a_b"
|
||||
|
||||
|
||||
def test_sanitize_filename_replaces_non_identifier_characters() -> None:
|
||||
assert sanitize_filename("My Root CA (v2).pem\n") == "My_Root_CA__v2__pem_"
|
||||
|
||||
|
||||
def test_sanitize_filename_keeps_letters_digits_underscore_and_dash() -> None:
|
||||
assert sanitize_filename("Inter_Diode-2026") == "Inter_Diode-2026"
|
||||
|
||||
|
||||
def test_sanitize_filename_never_returns_dot_names() -> None:
|
||||
assert sanitize_filename(".") == "_"
|
||||
assert sanitize_filename("..") == "__"
|
||||
|
||||
|
||||
def test_sanitize_filename_never_returns_empty_string() -> None:
|
||||
assert sanitize_filename("") == "_"
|
||||
|
||||
Reference in New Issue
Block a user