-
-
Notifications
You must be signed in to change notification settings - Fork 13
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
validate_filename() and sanitize_filename() pass '.' and '..' #19
Comments
Was this ever resolved? I have the same issue in 2.5.2 It would be great if |
I have considered this previously and concluded that it is difficult to apply replacements unconditionally. In the future, another solution may be to add an interface that specifies a callback function to process reserved names. |
I agree that they probably shouldn't be replaced in I suppose if people are using |
from pathvalidate import sanitize_filename, ValidationError
def add_trailing_underscore(e: ValidationError) -> str:
if e.reusable_name:
return e.reserved_name
return f"{e.reserved_name}_"
sanitize_filename(".", reserved_name_handler=add_trailing_underscore, additional_reserved_names=["."])
|
In pathvalidate 2.4.1:
I know that
.
and..
can be valid in a path, but surely not as filenames on any of the supported platforms?Thanks.
Edited to add:
My expectation would be that
validate_filename()
would perhaps raise a ValidationError with a reason ofRESERVED_NAME
in the two cases above?Also, if these are considered reserved filenames, shouldn't
_
be appended to each, as with, for example:sanitize_filename("con")
returnscon_
?The text was updated successfully, but these errors were encountered: