VSCode can still create "invalid" files/folders on Windows #59850
Labels
bug
Issue identified by VS Code Team member as probable bug
windows
VS Code on Windows issues
workbench-cli
VS Code Command line issues
Milestone
Issue Type: Bug
This references #1579 which was about the same problem already (originally in the save dialog, but further down also about special filenames from the command line).
I'm still able to accidentally create hard-to-delete files and folders with VSCode in Windows, which I believe is bad UX and I see an effort to prevent this (e.g. trying to save
NUL
orabc?*
is actively prevented), so I think this counts as a bug.Creating invalid folders: Start code.exe/code.bat with a parameter like
C:\nope...\wtf.txt
. Good luck getting rid of the foldernope...
afterwards (worse with...
alone of course which can end up deleting the whole drive instead if you are not careful). Reason: Seems like you are not validating the directories in the given path.Creating invalid files: Either start code.exe/code.bat with a parameter like
NUL.txt
or create such a file in the project explorer sidebar. Note that you cannot delete the file even in the sidebar when you created it there! While doing so, by the way, you will notice that upon enteringNUL
an error is shown, butNUL.txt
is accepted. Reason: Seems like you are comparing against a known list of invalid names and not applying the actual rules.A good read about these problems is this article.
A solution could be calling
fs.realpath.native
, which usesGetFullPathName
to get the resolved path (instead ofpath.resolve
) and further verifying that the result...\\.\
or\\?\
(rules out most cases, since for exampleC:\abc\COM1.txt
would have become\\.\COM1
at that point)X:\??\
whereX
can be any character (rules out the case incorrectly handled byGetFullPathName
where Windows accepts\??\
as alias for\\?\
):;\/|<>?*"
)...and additionally check that after removing one path segment after another, the above conditions still hold.
(But yeah I know that this probably won't be worth the effort. It's up to you to decide about that though.)
VS Code version: Code - Insiders 1.28.0-insider (60db21f, 2018-10-02T13:26:37.890Z)
OS version: Windows_NT x64 10.0.17134
System Info
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Extensions (85)
The text was updated successfully, but these errors were encountered: