-
Notifications
You must be signed in to change notification settings - Fork 16
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
\
is a valid filename character on Linux
#53
Comments
\\
is a valid filename character on Linux\
is a valid filename character on Linux
Isn't |
|
Well, it seems its a valid char indeed... this is clearly not handled & I am not sure how it should be best handled. On Windows it's considered a path separator, hence a filename with it is converted to the unix separator. We need to somehow decide we are coming from a Unix path and it's a normal char, and it should not be converted to a unix dir separator. But I think there is no straight forward way to determine if the I think thought it's a very rare case though, noone else has raised this issue... Any ideas or PRs are welcome ;-) |
Just my two cents: I have never seen nor expected to use I would be very curious to hear what use case this has, since even if it is a valid filename char doesn't mean it's widely used enough to support an edge case like this, and I would also be curious if Personally, if I saw this in a code review, I'd absolutely call it into question since this seems rife for causing unintended problems down the line, whether with OS/file system portability or just filepath maintenance in the app longer term. Additionally, POSIX path normalization via Treating |
When you have a set A (windows paths) that is a subset of a set B (unix paths), then you can always go A -> B. If you need to be multi-platform you can restrict yourself to A, which is what this library currently does and what @bmcminn is arguing for. There are cases where you may need to support everything that B allows (file names outside of your control, generated or not). For A -> B you map For B -> A, in B you can simply treat So you need a concept of "this is a path in B (where It may be more complicated than that because there may be more than just A and B. |
There are some decent conversations on the topic here that go into the more general question of "which characters are valid filename chars in linux?" and that is basically anything that isn't https://unix.stackexchange.com/questions/230291/what-characters-are-valid-to-use-in-filenames Though I don't think it necessarily justifies the use of
15+ years in software development and this just feels like a footgun waiting to happen, especially in the context of any sort of cross platform application development. If it was supported in both Unix and Windows, then that might be a valid justification, but this seems like an esoteric code smell that could just be left out. Folx can handle an edge case like this in conjunction with this library and appending the filename in question: let filepath = path.join(process.cwd(), '/path/to', custom_directory) + '/my\\wierd\\filename' |
Was this overlooked?
The text was updated successfully, but these errors were encountered: