helix
helix copied to clipboard
Don't try to open non-regular files
Summary
Helix should only open regular files. Non regular files like devices and pipes should be rejected.
This can be fixed by checking FileType::is_file.
I can open a PR to fix it :)
Reproduction Steps
The following command will freeze and continuously eat RAM.
hx /dev/random
The following command just freezes:
mkfifo pipe
hx pipe
Platform
Relevant on Unix but probably also on Windows
Helix Version
helix 24.3 (f656b4f3)
That seems mostly correct and match vim but symlinks should still be opened if they point qt a file or directory. Not sure how is_file handles those
fs::metadata traverses symlinks so is_file would return true.
The weird thing is that not every method returning Metadata traverses symlinks. One needs to read its docs. For example, DirEntry::metadata does NOT traverse symlinks.
My first thought was "why?" but yeah, the more I think about it, apart from symlinks that point to regular files or directories, I can't think of a use case where any other file type makes sense. Editing a pipe, character device, block device, etc just doesn't make any sense. We need to be able to read the whole file and write back to it, and no other file type fits this pattern.
I believe this can be closed now since #10733 is merged.
(Off-topic: Congratulations on Rustlings rewrite :))