Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regression in "." and ".." reserved names in v3.2.2 #59

Closed
slingshotvfx opened this issue Jan 2, 2025 · 2 comments · Fixed by #60
Closed

regression in "." and ".." reserved names in v3.2.2 #59

slingshotvfx opened this issue Jan 2, 2025 · 2 comments · Fixed by #60

Comments

@slingshotvfx
Copy link

slingshotvfx commented Jan 2, 2025

Due to these changes:
d94185a#diff-50b900757c3f8a8a6773c06200526edaec2b20b6543e722d32a36fc1f09abaa5L237

Using . or .. as additional_reserved_names no longer works as expected:

from pathvalidate import sanitize_filename

print(sanitize_filename("..", additional_reserved_names=[".", ".."]))
print(sanitize_filename(".", additional_reserved_names=[".", ".."]))

result:

_._._
_._

For my specific use case, I want to sanitize "." and ".." filenames on windows (as recommended here):

def add_trailing_underscore(e: ValidationError) -> str:
    if e.reusable_name:
        return e.reserved_name

    return f"{e.reserved_name}_"


print(sanitize_filename("..", reserved_name_handler=add_trailing_underscore, additional_reserved_names=[".."]))

In v3.2.1 this printed .._ but in v3.2.2 it prints _._._

Thanks!

thombashi added a commit that referenced this issue Jan 3, 2025
Signed-off-by: Tsuyoshi Hombashi <tsuyoshi.hombashi@gmail.com>
@thombashi
Copy link
Owner

@slingshotvfx
Thank you for your report.
The problem has been fixed at pathvalidate 3.2.3

@slingshotvfx
Copy link
Author

3.2.3 works for me, thanks for fixing it so quickly!

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 a pull request may close this issue.

2 participants