Created attachment 124435 [details] [review]
Patch to fix the x-scheme open issue.
I'm using version 1.1.1 on Arch Linux, but that wasn't available in the drop-down so I chose the closest version.
Opening a magnet link with xdg-open will open that link in the default bittorrent application.
Opening a magnet link with xdg-open opens the link with the browser set by $BROWSER.
Steps to reproduce:
1. Set the BROWSER environment variable to any browser.
2. Run `xdg-open magnet:?xt=foo`.
3. The magnet link will be opened by the browser instead of the default application for magnet links.
I first noticed this issue when clicking a magnet link in Chromium/Chrome would open a new tab. Since Chromium uses xdg-open, I first checked to make sure `xdg-mime query default x-scheme-handler/magnet` returned my default torrent application. Since xdg-mime reported the correct default application, I looked in xdg-open to see why it was opening my browser instead. I managed to find the problem code here:
817 if [ -n "$BROWSER" ]; then
818 open_envvar "$1"
821 if [ -n "$DISPLAY" ]; then
822 open_generic_xdg_x_scheme_handler "$1"
825 # if BROWSER variable is not set, check some well known browsers instead
826 if [ x"$BROWSER" = x"" ]; then
828 if [ -n "$DISPLAY" ]; then
833 open_envvar "$1"
835 exit_failure_operation_impossible "no method available for opening '$1'"
Since $BROWSER is defined in my .bashrc, the first code path (`open_envvar "$1"`) and `open_generic_xdg_x_scheme_handler "$1"` is never reached. To fix this, I removed lines 817-819. Since the `open_envvar "$1"` will happen eventually if $DISPLAY is not set, this shouldn't drastically change how this piece of code works.
For convenience, I've attached the patch I made to this message.
yeah, the 'open in a browser' last-ditch fallback probably needs to go away, but these patch only partially removes it, so not good enough.
I think I'll just bump it's prority down, so that open_generic_xdg_x_scheme_handler comes before.
That commit breaks an autotest for xdg-open. The test case is named "always uses $BROWSER if set in generic mode". So I think you "patched" an intended behaviour. Or that test should be rewritten.
Well, I'm reopening the bug because this situation needs to be solved.
"always uses $BROWSER if set in generic mode" is definitely not ideal now, that test's assumptions are now indeed invalid.
-- GitLab Migration Automatic Message --
This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.
You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/xdg/xdg-utils/issues/88.