Summary
sanitize_filename and sanitize_filepath does not detect reserved names after stripping leading spaces such as " AUX"
Description
When the input contains a reserved name with leading spaces (e.g. " AUX"), both sanitize_filename and sanitize_filepath strip the spaces but fail to recognize the resulting string as a reserved name.
Expected Behavior
After stripping spaces, the result should be recognized as a reserved name and handled accordingly (e.g. " AUX" → "AUX_").
Code to reproduce
from pathvalidate import sanitize_filename, sanitize_filepath
# sanitize_filename
print(sanitize_filename("AUX", platform="Windows")) # 'AUX_' ✅
print(sanitize_filename(" AUX", platform="Windows")) # 'AUX' ❌
# sanitize_filepath
print(sanitize_filepath("AUX", platform="Windows")) # 'AUX_' ✅
print(sanitize_filepath(" AUX", platform="Windows")) # 'AUX' ❌
print(sanitize_filepath(" NUL.txt", platform="Windows")) # 'NUL.txt' ❌
Your Environment
| Module |
Version |
| uname |
Windows 10 |
| Python |
CPython 3.12.3 |
| platform |
10 10.0.19045 SP0 |
| pathvalidate |
3.3.1 |
Summary
sanitize_filename and sanitize_filepath does not detect reserved names after stripping leading spaces such as " AUX"
Description
When the input contains a reserved name with leading spaces (e.g. " AUX"), both sanitize_filename and sanitize_filepath strip the spaces but fail to recognize the resulting string as a reserved name.
Expected Behavior
After stripping spaces, the result should be recognized as a reserved name and handled accordingly (e.g. " AUX" → "AUX_").
Code to reproduce
Your Environment