Closed TeoKn closed 3 years ago
Thank you for your report.
This behavior is expected.
As the description of the error message, it is impossible to create an absolute file path for universal
(operating system independent) platform.
Thank you for your comment although it does not seem to be about my report. The question is to sanitize a path, not to create it. Moreover, under Unix, Linux, FreeBSD, etc., paths can be created independently of being absolute or relative. (Only file/directory permissions matter.)
There is no reason for sanitize_filepath
, when called with platform="Linux"
or platform="auto"
, to return the original path whereas the latter contains shell-reserved characters (please, have a look at In [6] and In [7] of sanitize-filepath-bug.pdf).
In addition, if an absolute path may be problematic for some platforms (certainly not for Linux), sanitize_filepath
could return an equivalent relative path.
The question is to sanitize a path, not to create it.
I mean, create a sanitized file path by sanitize_filepath
function.
Moreover, under Unix, Linux, FreeBSD, etc., paths can be created independently of being absolute or relative. (Only file/directory permissions matter.)
In sanitize_filepath
, platfrom=universal
includes Windows. POSIX abspath and Windows abspath are incompatible.
There is no reason for sanitize_filepath, when called with platform="Linux" or platform="auto", to return the original path whereas the latter contains shell-reserved characters
There is a reason. shell-reserved characters like vertical line (|
) can be used for file names when creating files outside shells.
You can use replace_symbol
function to remove such characters.
Whereas
sanitize_filepath
works perfectly for a relative path, it has an unexpected behaviour on absolute paths. It either rises an exception or, whenplatform
is specified as 'auto' or 'Linux', it lefts the string unchanged.The execution (see sanitize-filepath-bug.pdf) has been run with Python 3.8.5 under Linux (Ubuntu 20.04.2 LTS). I've just installed for the first time
pathvalidate
today via pip.