Byron / open-rs

Open a path or URL with the system-defined program
http://byron.github.io/open-rs
MIT License
319 stars 49 forks source link

On Windows, using a path to locate an app doesn't work if the path has spaces in it. #85

Closed xalbd closed 11 months ago

xalbd commented 11 months ago

Let's attempt to open a file C:\file.jpg using the program C:\Program Files\Google\Chrome\Application\chrome.exe.

open::with("C:\\file.jpg", "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe").unwrap();

This results in an error as Windows says it cannot find C:\Program. This seems to be caused by the same issue that was addressed for file paths in #53.

https://github.com/Byron/open-rs/blob/a33caba441354a14bd55a16ad4a5e8bc793819f0/src/windows.rs#L25-L26

A simple fix would be to call the same wrap_into_quotes on app. I just tested this fix in a fork and it works; let me know if you'd like me to open a PR.

This issue was originally discovered here: https://github.com/typst/typst/issues/2724

Byron commented 11 months ago

Thanks so much for letting me know and offering a fix - a PR would be greatly appreciated.

xalbd commented 11 months ago

Awesome! Just created PR #86. Thanks for the quick response!