thombashi / pathvalidate

A Python library to sanitize/validate a string such as filenames/file-paths/etc.
https://pathvalidate.rtfd.io/
MIT License
210 stars 12 forks source link

Name of only whitespace erroneously fails validation on linux #15

Closed Traktormaster closed 3 years ago

Traktormaster commented 3 years ago

File names that consist of whitespace characters only are valid on my system. I'm on Linux 5.9.6, I don't know if such file names are also valid for MacOS or not.

>>> validate_filename("  ", platform="linux")
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/home/joe/.venv/lib/python3.8/site-packages/pathvalidate/_filename.py", line 249, in validate_filename
    FileNameValidator(
  File "/home/joe/.venv/lib/python3.8/site-packages/pathvalidate/_filename.py", line 134, in validate
    validate_pathtype(value)
  File "/home/joe/.venv/lib/python3.8/site-packages/pathvalidate/_common.py", line 41, in validate_pathtype
    raise ValidationError(
pathvalidate.error.ValidationError: reason=NULL_NAME, description=the value must be a not empty
thombashi commented 3 years ago

Thank you for your report.

file name/path that consists only whitespaces are now accepted with pathvalidate 2.3.1.

>>> from pathvalidate import validate_filename
>>> validate_filename("  ", platform="linux")
>>>