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.
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:
I'm on Linux
5.11.10
, I don't know if such file names are also valid for MacOS or not.