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

Many name validations that include '\' (backslash) fail on Linux #18

Closed
Traktormaster opened this issue Mar 29, 2021 · 1 comment
Closed
Assignees
Labels

Comments

@Traktormaster
Copy link

The root of the problem seems to be that even on a non-windows platform the backslash is treated as a path separator character, leading to false absolute path detections. The following script demonstrates the problem with a few examples:

>>> from pathvalidate import validate_filename, ValidationError
>>> for name in ["\\", "\\\\", "\\ ", "C:\\", "c:\\", "\\xyz", "\\xyz "]:
...     try:
...         validate_filename(name, platform="linux")
...     except ValidationError as e:
...         print(e.reason, "for", repr(name))
...     else:
...         raise Exception("did not raise for %r" % (name,))
...     
ErrorReason.FOUND_ABS_PATH for '\\'
ErrorReason.FOUND_ABS_PATH for '\\\\'
ErrorReason.FOUND_ABS_PATH for '\\ '
ErrorReason.FOUND_ABS_PATH for 'C:\\'
ErrorReason.FOUND_ABS_PATH for 'c:\\'
ErrorReason.FOUND_ABS_PATH for '\\xyz'
ErrorReason.FOUND_ABS_PATH for '\\xyz '

I'm on Linux 5.11.10, I don't know if such file names are also valid for MacOS or not.

@thombashi thombashi added the bug label Apr 3, 2021
@thombashi thombashi self-assigned this Apr 3, 2021
thombashi added a commit that referenced this issue Apr 3, 2021
that include '\' (backslash) on other than Windows.
@thombashi
Copy link
Owner

Thank you for your report.
The problem has fixed at pathvalidate 2.4.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants