firecat53 / urlscan

Mutt and terminal url selector (similar to urlview)
GNU General Public License v2.0
211 stars 36 forks source link

xdg-open handler opens link 3 times instead of 1 #126

Closed havardjohn closed 2 years ago

havardjohn commented 2 years ago

I have urlscan installed on version 0.9.9 for Linux with python 3.10.4, urwid 2.1.2, glibc 2.35. Installed urlscan with python setup.py build && python setup.py install --root=pkg --optimize=1. No configuration file is present in ~/.config/urlscan/config.json. I can reproduce this in urlscan 0.9.6 as well. I have detailed the issue in the following 2 examples.

Example 1

I run the command urlscan /tmp/test1.txt where the contents of /tmp/test1.txt is https://duckduckgo.com (or any other web page link). I press l to select the Xdg-Open link handler, and then press Enter. Then 3 tabs in qutebrowser is opened, each opening https://duckduckgo.com. Expected behavior is that only 1 tab is opened.

When I run xdg-open https://duckduckgo.com, only 1 tab in qutebrowser is opened. The same happens if I use the browser handler in urlscan instead of the Xdg-Open. I have set environment variable BROWSER to qutebrowser. Without this variable set, only 2 instances are opened in the Xdg-Open handler, but one tab is in chromium and the other in qutebrowser. chromium is not present in ~/.config/mimeapps.list.

Example 2

Another example is when I run the command urlscan /tmp/test2.txt where the contents of /tmp/test2.txt is mailto:bob@bob.com. I have setup xdg-open to open neomutt for these links. I press l inside urlscan to select the Xdg-Open link handler, and then press Enter. neomutt is started to write an email. I finish writing the email, and send or abort it. After that, neomutt closes and 2 new tabs in qutebrowser is opened, each opening mailto:bob@bob.com (an empty page). Expected behavior is that no tabs are opened in qutebrowser.

In the previous paragraph, BROWSER env was set to qutebrowser. If this variable is unset, instead of 2 new tabs opening in qutebrowser, 1 tab in chromium is opened. The expected behavior here is that chromium is not opened.


I am willing to try to help solve this, but would like to know if there is any insight into this first. Thank you. :)

firecat53 commented 2 years ago

I'm sorry, but I can't reproduce your issue with any of your examples. I also haven't received any other reports of a similar issue. I've been using (obviously :D) urlscan for years on Arch and Fedora primarily without any similar issues.

If I had to guess, I'd suspect something is messed up with xdg and/or mimetype handling on your system. Try installing urlscan in a virtualenv and then possibly spin up a fresh VM of $(distro) to try with a clean install.

havardjohn commented 2 years ago

I tested with the last commit just now, and it works as intended again! It only opens 1 tab now. I bisected, and found that the commit 224ded3 caused it to work again, but I cannot understand why from looking at the diff. Thank you for testing. :) Closing as resolved.

lucc commented 1 year ago

I was hit by the same issue and the current development version of urlscan also solves it for me.

@firecat53 can I urge you to make a release so that we can package and install this fix via our distros?

firecat53 commented 1 year ago

0.9.10 released. Thanks for the prompt!