Skip to content

Accept spaces in paths in http config setting #77

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

Closed
Jackymancs4 opened this issue Aug 28, 2020 · 5 comments
Closed

Accept spaces in paths in http config setting #77

Jackymancs4 opened this issue Aug 28, 2020 · 5 comments
Labels
bug Something isn't working
Milestone

Comments

@Jackymancs4
Copy link

Jackymancs4 commented Aug 28, 2020

Hello @makeworld-the-better-one
I'm using amfora 1.4 for linux on a Windows machine using WSL.

Obviously, in this setup there is no detectable GUI nor browser, so when trying to open an http link it fails.

To overcome this, I manually set the http setting value from default to /mnt/c/Program Files/Mozilla Firefox/firefox.exe.

Amfora then prompt me with:
Error executing custom browser command: fork/exec /mnt/c/Program: no such file or directory

It appears that the spaces in the path are not properly escaped.

So I chanced the setting to /mnt/c/Program\ Files/Mozilla\ Firefox/firefox.exe but again amfora prompt the error Error executing custom browser command: fork/exec /mnt/c/ProgramFiles/MozillaFirefox/firefox.exe: no such file or directory. which shows that the spaces have been removed.

@Jackymancs4
Copy link
Author

After a minor investigation I found that the issue originates here:
https://github.com/makeworld-the-better-one/amfora/blob/5e417b040bfdfb366fcdea0c95da496871db8833/display/private.go#L156

I see why you used strings.Fields, but a path with spaces is still a valid path.
Given the complexity of this kind of things, maybe a dedicated library like https://github.com/mattn/go-shellwords (from https://groups.google.com/g/golang-nuts/c/pNwqLyfl2co?pli=1)

@makew0rld makew0rld added the bug Something isn't working label Aug 28, 2020
@makew0rld
Copy link
Owner

Thanks for finding this, I see the problem. I will look into using go-shellwords, thanks for finding that library.

Can I ask why you're using Amfora through WSL instead of just on Windows directly?

@makew0rld makew0rld modified the milestones: v1.5.0, v1.6.0 Aug 28, 2020
@Jackymancs4
Copy link
Author

Can I ask why you're using Amfora through WSL instead of just on Windows directly?

No particular reason, I'm more of a Linux person, but have to use Windows for work (and games) so I try to replicate my terminal setup as much as possible on both platforms.

@makew0rld
Copy link
Owner

I was thinking about accepting an array of strings as well as just a single string for this setting, and all other shell command based settings. So if you want something other than the naive space splitting, you can do the splitting yourself with an array.

For your example:

http = ["/mnt/c/Program Files/Mozilla Firefox/firefox.exe"]

A more complex example, that fails with the current code:

http = ["some-command", "--flag", "/path/with spaces/here.txt"]

@Jackymancs4
Copy link
Author

The solution as you described sounds perfect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants