Skip to content
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

Prevent improper files (like /dev/random) from being used as file arguments #10733

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

TiredTumblrina
Copy link

As per the suggestions in #10726 this pull request changes the argument parsing to only add a PathBuf to args.files if it is either a file or a symlink. This has been tested on the scenarios provided in the issue and simply opens an empty buffer as if no argument was provided in those cases. (instead of freezing)

@pascalkuthe
Copy link
Member

I don't think the arg parsing is the right place to do this. We should fundamentally disallow opening non-files so it's consistent with :open/:vsplit and any other way a user would open a path

@TiredTumblrina
Copy link
Author

That is a good point, I'll see if I can get this to work in a more interoperable way and will amend the PR

@TiredTumblrina
Copy link
Author

By making changes to the Document::open method I have the :open command working as expected, however when I revert the prior changes to argument parsing the application errors out ungracefully:

> hx /dev/random
Error: unable to create new application

Caused by:
    0: open '/dev/random'
    1: Path argument /dev/random should lead is not a regular file or a symlink.

In this case, maybe it would be better to keep both checks so that the application does not crash when it gets an invalid input?

@kirawi
Copy link
Member

kirawi commented May 12, 2024

You probably need to handle that error and just create an empty scratch buffer if the file can't open.

@TiredTumblrina
Copy link
Author

done, thank you all for the suggestions and advice!

@kirawi kirawi added A-helix-term Area: Helix term improvements S-waiting-on-review Status: Awaiting review from a maintainer. labels May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants