[Portland-bugs] [Bug 96472] New: xdg-open opens magnet links in the browser instead of the default bittorrent application (suggested patch)

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Fri Jun 10 05:12:56 UTC 2016


https://bugs.freedesktop.org/show_bug.cgi?id=96472

            Bug ID: 96472
           Summary: xdg-open opens magnet links in the browser instead of
                    the default bittorrent application (suggested patch)
           Product: Portland
           Version: 1.1.0
          Hardware: All
                OS: Linux (All)
            Status: NEW
          Severity: normal
          Priority: medium
         Component: xdg-utils
          Assignee: portland-bugs at lists.freedesktop.org
          Reporter: cyrozap at gmail.com

Created attachment 124435
  --> https://bugs.freedesktop.org/attachment.cgi?id=124435&action=edit
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.


Expected behavior:

Opening a magnet link with xdg-open will open that link in the default
bittorrent application.


Actual behavior:

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"
819     fi
820 
821     if [ -n "$DISPLAY" ]; then
822         open_generic_xdg_x_scheme_handler "$1"
823     fi
824 
825     # if BROWSER variable is not set, check some well known browsers
instead
826     if [ x"$BROWSER" = x"" ]; then
827         BROWSER=www-browser:links2:elinks:links:lynx:w3m
828         if [ -n "$DISPLAY" ]; then
829            
BROWSER=x-www-browser:firefox:iceweasel:seamonkey:mozilla:epiphany:konqueror:chromium-browser:google-chrome:$BROWSER
830         fi
831     fi
832 
833     open_envvar "$1"
834 
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.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/portland-bugs/attachments/20160610/bf37495b/attachment.html>


More information about the Portland-bugs mailing list