<html>
<head>
<base href="https://bugs.freedesktop.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - xdg-open opens magnet links in the browser instead of the default bittorrent application (suggested patch)"
href="https://bugs.freedesktop.org/show_bug.cgi?id=96472">96472</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>xdg-open opens magnet links in the browser instead of the default bittorrent application (suggested patch)
</td>
</tr>
<tr>
<th>Product</th>
<td>Portland
</td>
</tr>
<tr>
<th>Version</th>
<td>1.1.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux (All)
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>medium
</td>
</tr>
<tr>
<th>Component</th>
<td>xdg-utils
</td>
</tr>
<tr>
<th>Assignee</th>
<td>portland-bugs@lists.freedesktop.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>cyrozap@gmail.com
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=124435" name="attach_124435" title="Patch to fix the x-scheme open issue.">attachment 124435</a> <a href="attachment.cgi?id=124435&action=edit" title="Patch to fix the x-scheme open issue.">[details]</a></span> <a href='page.cgi?id=splinter.html&bug=96472&attachment=124435'>[review]</a>
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.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>