-
Notifications
You must be signed in to change notification settings - Fork 453
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
fix opening filenames with spaces on linux #127
Conversation
Noticed this problem as well, but this is not actually enough since filenames can contain quotes as well! I solved this by appending a backslash in front of every character. (I wrote this in an email to the mantainer because I figured this might be a security vulnerability. It most likely isn't) |
I believe the best way to implement this is is to open the right process right away instead of using the |
@miDeb you have a good point. TBH, I also don't understand why the system call is used here. I assumed the author had good reasons.. but maybe not as good as I hope ;) maybe @crazecoder can chime in. I'll update my PR anyway to use Process |
- xdg-open is available on all platforms, no need for other variations - removed linux.dar: no longer needed
The same issue seems to exist on macOS fwiw. |
This removes the ability to use `system` to open files. Instead we use `Process.runSync`. Quoting the [manpage for `system`](https://man.archlinux.org/man/system.3): > Any user input that is employed as part of command should be carefully sanitized, > to ensure that unexpected shell commands or command options are not executed. AFAICT only spaces are replaced with `\ ` right now. This is not enough, and invoking the `system` function is also completely unnecessary. Creating a new process directly is both simpler and better. This option was introduced in crazecoder#127, however only on linux and not as the default. This is not sufficient. Running the following in an unsandboxed flutter app on linux would open `gnome-calculator` (if installed, but you can place any command in there that will be executed): ```dart OpenFile.open(";gnome-calculator"); ``` I haven't tested this on macOS but it _should_ work there similarly to linux.
This removes the ability to use `system` to open files. Instead we use `Process.runSync`. Quoting the [manpage for `system`](https://man.archlinux.org/man/system.3): > Any user input that is employed as part of command should be carefully sanitized, > to ensure that unexpected shell commands or command options are not executed. AFAICT only spaces are replaced with `\ ` right now. This is not enough, and invoking the `system` function is also completely unnecessary. Creating a new process directly is both simpler and better. This option was introduced in crazecoder#127, however only on linux and not as the default. This is not sufficient. Running the following in an unsandboxed flutter app on linux would open `gnome-calculator` (if installed, but you can place any command in there that will be executed): ```dart OpenFile.open(";gnome-calculator"); ``` I haven't tested this on macOS but it _should_ work there similarly to linux.
fixes #126
I'm not sure about the other platforms, so I stayed out of it..