Skip to content

Preserve extensions when replacing reserved filenames - #79

Open
Aminark wants to merge 2 commits into
thombashi:masterfrom
Aminark:fix/preserve-reserved-name-extensions
Open

Aminark wants to merge 2 commits into
thombashi:masterfrom
Aminark:fix/preserve-reserved-name-extensions

Conversation

@Aminark

@Aminark Aminark commented Oct 25, 2026

Copy link
Copy Markdown

sanitize_filename("con.icon", platform="windows") currently returns con_.icon_: the reserved-name replacement also changes matching text inside the extension. CON.CON.txt is affected too.

Limit the replacement to its first occurrence. Added tests for both underscore handlers, Windows/universal platforms, custom reserved names, and sanitize_filepath.

Tested on Python 3.12: python -m pytest -q (4185 passed, 17 skipped). Formatting and import checks pass for the changed files; Ruff diagnostics in _filename.py are unchanged from master.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant