open_filex icon indicating copy to clipboard operation
open_filex copied to clipboard

Linux and Macos file opening fix

Open prateekmedia opened this issue 2 years ago • 4 comments

This PR reduces the code from two files to 4 lines and also fixes the error in linux and mac on opening of files with special characters.

More info from on crazecoder/open_file#156:

This removes the ability to use system to open files. Instead we use Process.runSync.

Quoting the manpage for system:

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 #127, however only on linux and not as the default. This is not sufficient.

Without this PR, 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):

  OpenFile.open(";gnome-calculator");

I haven't tested this on macOS but it should work there similarly to linux.

prateekmedia avatar Jan 05 '23 09:01 prateekmedia

@javaherisaber can you merge this please?

prateekmedia avatar Apr 16 '23 04:04 prateekmedia

@prateekmedia Thanks for your contribution to the repo and sorry for the delay, I've been busy with my projects. I'll try to verify the changes and will keep you posted on this thread

javaherisaber avatar Apr 17 '23 15:04 javaherisaber

It may have some merge conflicts as it is not my code, but from my side it is verified to be legitimate and working.

prateekmedia avatar Apr 17 '23 15:04 prateekmedia

@prateekmedia See this comment related to your PR

javaherisaber avatar Dec 31 '23 11:12 javaherisaber