webbrowser incorrectly handles quoted arguments for GNOME browser configuration

Bug #83974 reported by Janek
122
Affects Status Importance Assigned to Milestone
apport (Ubuntu)
Invalid
Undecided
Unassigned
Declined for Feisty by Martin Pitt
firefox (Ubuntu)
Invalid
High
Unassigned
Declined for Feisty by Martin Pitt
python2.5 (Ubuntu)
Invalid
Medium
Unassigned
Declined for Feisty by Martin Pitt

Bug Description

>>> import webbrowser
>>> webbrowser.open('http://www.piware.de')

-> opens file:///home/martin/%22http://www.piware.de%22

This happens with

  $ gconftool --get /desktop/gnome/url-handlers/http/command
  /usr/lib/firefox/firefox "%s"

which is what upstream firefox sets if you check for default browser.

Janek (thefoxx)
description: updated
Changed in apport:
importance: Undecided → Low
status: Unconfirmed → Confirmed
Revision history for this message
Martin Pitt (pitti) wrote :

What does

  gconftool --get /desktop/gnome/url-handlers/http/command

print out for you?

I cannot reproduce this at all, nothing in apport itself produces a file:// url.

Changed in apport:
importance: Low → Undecided
status: Confirmed → Needs Info
Changed in apport:
importance: Undecided → High
status: Needs Info → Confirmed
Revision history for this message
Emilio Pozuelo Monfort (pochu) wrote :

No problem here. This is the output:

emilio@kiko:~$ gconftool --get /desktop/gnome/url-handlers/http/command
firefox %s

Revision history for this message
Emilio Pozuelo Monfort (pochu) wrote :

Pitti, sorry for the change ;) We did it at the same time :D

Changed in apport:
importance: High → Undecided
status: Confirmed → Needs Info
Revision history for this message
marcobra (Marco Braida) (marcobra) wrote :

I have same problem and my Feisty with:
gconftool --get /desktop/gnome/url-handlers/http/command

print:

/home/danilo/firefox/firefox "%s"

I use last devel of Firefox Minefield installed into:

/home/danilo/firefox/firefox

HTH

Revision history for this message
marcobra (Marco Braida) (marcobra) wrote :

After updates:

python-problem-report 0.52
python-apport 0.52
python-launchpad-bugs 0.1~r76
apport 0.52
apport-gtk 0.52

I get the same problem.

Revision history for this message
Emilio Pozuelo Monfort (pochu) wrote :

Still no problem here after updating :)

Revision history for this message
Janek (thefoxx) wrote :

I upgraded to apport 0.52 and have still the problem.

$ gconftool --get /desktop/gnome/url-handlers/http/command
/usr/lib/firefox/firefox "%s"

Revision history for this message
Martin Pitt (pitti) wrote :

elart, which URL is opened for you?

Revision history for this message
marcobra (Marco Braida) (marcobra) wrote :

Running:
gconftool --get /desktop/gnome/url-handlers/http/command

i get

/opt/firefox/firefox "%s"

I have firefox 3alpha3 as default browser and it is installed in
/opt/firefox/firefox

When i try to report a problem the link put always "file:///my user home path" as you can see is "file:///home/danilo/"

file:///home/danilo/%22https://edge.launchpad.net/ubuntu/+filebug/um....%22

HTH

Revision history for this message
marcobra (Marco Braida) (marcobra) wrote :

I get the last upgrade and i still get wrong http address...

HTH

Revision history for this message
Emilio Pozuelo Monfort (pochu) wrote :

Does this happen to you always are just with apport links?

For example, if you open rhythmbox>help>about and click the link, does it open well, or has that the same problem?

Revision history for this message
Martin Pitt (pitti) wrote :

Can you please upgrade to this version (at least python-apport):

 apport (0.53) feisty; urgency=low
 .
   * apport/ui.py, open_url(): Remove some accidentally left-over debugging
     junk.
   * gtk/apport-gtk: Process pending GTK events after hiding the info
     collection window to avoid a hanging dead dialog.
   * gtk/apport-gtk: Do not count the lines of fields with binary data. This
     particularly avoids long delays with huge core dumps. (LP: #81979)
   * apport/ui.py, open_url(): Print URL to stdout, so that we can debug the
     weirdness in #83974.

and with that, run apport-gtk from the command line? Like this:

  /usr/share/apport/apport-gtk -f -p bash

It should print the URL that is submitted to the open_url() function. Is it the correct one?

If you click on a link in a terminal window, does that work?

Revision history for this message
marcobra (Marco Braida) (marcobra) wrote :

> Does this happen to you always are just with apport links?

I think i have problem only with apport links

> For example, if you open rhythmbox>help>about and click the link, does it open well, or has that the same problem?

All the link of rhythmbox>help> ... works fine only the "bug notify" have same problem:

file:///home/danilo/%22https://edge.launchpad.net/ubuntu/+source/rhythmbox/+filebug/kgaSBmfCNp3kOH5BqPkiSo9HeCG?%22

HTH

Revision history for this message
marcobra (Marco Braida) (marcobra) wrote :

> Can you please upgrade to this version (at least python-apport):
> apport (0.53) feisty; urgency=low

Can you tell me what i can do to get it...

Revision history for this message
marcobra (Marco Braida) (marcobra) wrote :

With last repos apport:

/usr/share/apport/apport-gtk -f -p bash

don't show the url but the browser start with this http address

file:///home/danilo/%22https://edge.launchpad.net/ubuntu/+source/bash/+filebug/sYpsA2SLrPrlUbIMjNfbo4biMgP?%22

HTH

Revision history for this message
Emilio Pozuelo Monfort (pochu) wrote :

Hi elart

Which apport version are you running?

dpkg -l apport

Thanks
Emilio

Revision history for this message
marcobra (Marco Braida) (marcobra) wrote :

dpkg -l apport

0.52

Revision history for this message
Emilio Pozuelo Monfort (pochu) wrote :

As Martin said, you should try with 0.53

To get that version, just wait a little (maybe a few minutes, maybe an hour) and do:

sudo aptitude update && sudo aptitude install apport

Then try again.

Thanks
Emilio

Revision history for this message
Emilio Pozuelo Monfort (pochu) wrote :

It's now in the repos.

Try this instead:
sudo aptitude update && sudo aptitude dist-upgrade

Regards
Emilio

Revision history for this message
marcobra (Marco Braida) (marcobra) wrote :

Now apport is updated to 0.53

But there is the same http address problem...

with rhythmbox bug report
file:///home/danilo/%22https://edge.launchpad.net/ubuntu/+source/rhythmbox/+filebug/2pibIdKrXgICusaBF9ygJFSuaYB?%22

with: "Report Problem"
file:///home/danilo/%22https://edge.launchpad.net/ubuntu/+filebug/4YylZX5v2oxOXQHZL852tQtb44f?%22

with:
/usr/share/apport/apport-gtk -f -p bash

file:///home/danilo/%22https://edge.launchpad.net/ubuntu/+source/bash/+filebug/74QdDpH0Q3SVwTSTxuGdZCT1zBl?%22

HTH

Revision history for this message
marcobra (Marco Braida) (marcobra) wrote :

...
 /usr/share/apport/apport-gtk -f -p bash

It should print the URL that is submitted to the open_url() function. Is it the correct one?

The printed url is:
open_url: opening https://edge.launchpad.net/ubuntu/+source/bash/+filebug/l9qGUaS93XdcyomlMwsaRlSpniy?

HTH

Revision history for this message
marcobra (Marco Braida) (marcobra) wrote :

I don't know if is related to this, but reading: /var/log/messages

Feb 12 18:54:32 ubuntu gconfd (danilo-4725): L'indirizzo "xml:readonly:/etc/gconf/gconf.xml.mandatory" è stato risolta ad una sorgente di configurazione in sola lettura in posizione 0
Feb 12 18:54:32 ubuntu gconfd (danilo-4725): L'indirizzo "xml:readwrite:/home/danilo/.gconf" è stato risolto ad una sorgente di configurazione scrivibile in posizione 1
Feb 12 18:54:32 ubuntu gconfd (danilo-4725): L'indirizzo "xml:readonly:/etc/gconf/gconf.xml.defaults" è stato risolta ad una sorgente di configurazione in sola lettura in posizione 2
Feb 12 18:54:32 ubuntu gconfd (danilo-4725): L'indirizzo "xml:readonly:/var/lib/gconf/debian.defaults" è stato risolta ad una sorgente di configurazione in sola lettura in posizione 3
Feb 12 18:54:32 ubuntu gconfd (danilo-4725): L'indirizzo "xml:readonly:/var/lib/gconf/defaults" è stato risolta ad una sorgente di configurazione in sola lettura in posizione 4

HTH

Revision history for this message
Martin Pitt (pitti) wrote :

OK, so the computed URL is right, it seems to get mangled when calling firefox or gnome-open.

What happens if you do this on the command line:

  firefox https://edge.launchpad.net/ubuntu/+source/bash/+filebug
  gnome-open https://edge.launchpad.net/ubuntu/+source/bash/+filebug

Does either or both show this error?

Revision history for this message
Janek (thefoxx) wrote :

It works fine now! I have apport/apport-gtk 0.54. Thanks for fixing.

Revision history for this message
marcobra (Marco Braida) (marcobra) wrote :

firefox https://edge.launchpad.net/ubuntu/+source/bash/+filebug
open firefox and go on launchpad --> OK

gnome-open https://edge.launchpad.net/ubuntu/+source/bash/+filebug
open firefox and go on launchpad --> OK

HTH

Revision history for this message
marcobra (Marco Braida) (marcobra) wrote :

Just updated to apport 0.54 still problem...

HTH

Revision history for this message
JK (jk4-deactivatedaccount) wrote :

The problem is that when apport send the url to firefox there is a set of paranthesis wrapped around the url string. If one opens the terminal and does firefox "\"http://www.google.com\"" the problem is accurately replicated. This is the same problem. the %22 in the url are double quotes. Good luck, gents.

Revision history for this message
JK (jk4-deactivatedaccount) wrote :

One more crucial thing: In prefered applications my webbrowser was set to
/usr/lib/firefox/firefox "%s" Upon removing the quotes from %s, apport worked perfectly. So whatever is setting it to firefox with "%s" is causing the issue on the affected systems.

Revision history for this message
JK (jk4-deactivatedaccount) wrote :

More info: The double quoted web browser preference is set by firefox itself. If you clear the box for prefered web browser and then tell firefox to check whether it is the default www browser it will ask to make it so. Upon telling it to make itself the default the prefered web browser is /usr/..firefox "%s".

Revision history for this message
marcobra (Marco Braida) (marcobra) wrote :

You are right if i try:
firefox "\"http://www.google.com\""

the browser try to open:
file:///home/danilo/%22http://www.google.com%22

If i go to "Control center" and from "Set preferred applications" and changing
/opt/firefox/firefox "%s" to /opt/firefox/firefox %s all goes fine.

HTH

Revision history for this message
Janek (thefoxx) wrote :

yes, It looks all right but I said it already: Here all is working. But first after a reboot. Please try that. Maybe the "apport-watcher" or whatelse is used to check if there cames a bug have to be restarted...

Revision history for this message
marcobra (Marco Braida) (marcobra) wrote :

After reboot all works perfectly

HTH

Revision history for this message
Martin Pitt (pitti) wrote :

Ah, thanks a lot for tracking this down. Apport does nothing else than

   subprocess.call(['gnome-open', url])

thus apport does not do any quoting at all. So it seems that gnome-open itself does the double-quoting. I guess this affects opening other URLs as well.

Changed in apport:
importance: Undecided → High
status: Needs Info → Confirmed
Revision history for this message
Martin Pitt (pitti) wrote :

I am not entirely sure whether gnome-open should just deal with "%s" and not quote the substitution again (prefered, since that would unbreak existing broken configurations) or whether it is a Firefox bug and Firefox should actually just use 'firefox %s' as default gnome-open configuration.

Revision history for this message
Martin Pitt (pitti) wrote :

Discussed that with Sebastian. The quotes are illegal in the gconf preferences, this should be fixed in Firefox.

For anyone who is affected by this: Please open 'prefered applications' in the control center and set the browser back to 'firefox', or alternatively leave it to 'user defined' and remove the quotes around the %s.

Revision history for this message
Martin Pitt (pitti) wrote :

Aah, got it finally: apport 0.54 had a forgotten debugging change that made it fall through using webbrowser.open(). This is the culprit, it seems to quote arguments and call gnome-open through a shell, instead of calling it directly:

>>> import webbrowser
>>> webbrowser.open('http://www.piware.de')

-> opens file:///home/martin/%22http://www.piware.de%22

This happens with

  $ gconftool --get /desktop/gnome/url-handlers/http/command
  /usr/lib/firefox/firefox "%s"

which is what upstream firefox sets if you check for default browser.

This also explains why it is fixed in python-apport 0.54, where the debugging junk has been removed and gnome-open/firefox is called directly.

Changed in libgnome:
status: Unconfirmed → Confirmed
Revision history for this message
Martin Pitt (pitti) wrote :

Closing firefox task, the gconf setting works fine with calling gnome-open directly, thus this is a bug in Python's webbrowser module.

Changed in firefox:
status: Confirmed → Rejected
Revision history for this message
Martin Pitt (pitti) wrote :

Closing apport task, since this is a Python module bug and it does not apply any more to a standard Gnome/KDE desktop.

Changed in apport:
status: Unconfirmed → Rejected
description: updated
Revision history for this message
Matthias Klose (doko) wrote : Re: webbrowser incorrectly handles quoted arguments

... and not a python bug

Changed in python2.5:
status: Confirmed → Rejected
Revision history for this message
Martin Pitt (pitti) wrote :

dpkg -S /usr/lib/python2.5/webbrowser.py
python2.5: /usr/lib/python2.5/webbrowser.py

Why do you think it's not a Python bug? Running firefox or gnome-mount manually works just fine, but it breaks when using the webbrowser module. It seems it does some double-quoting, weird interpolation, or shell call where it shouldn't.

Changed in python2.5:
status: Rejected → Confirmed
Revision history for this message
Matt Zimmerman (mdz) wrote :

Yes, this behaviour can be replicated by e.g.:

firefox '"http://www.piware.de"'

so the problem is spurious quoting somewhere.

The webbrowser module interprets the gconf value as whitespace-separated arguments:

        # get the web browser string from gconftool
        gc = 'gconftool-2 -g /desktop/gnome/url-handlers/http/command 2>/dev/null'
[...]
            register("gnome", None, BackgroundBrowser(commd.split()))

whereas gnomevfs uses g_shell_parse_argv:

        path = g_strconcat (GCONF_URL_HANDLER_PATH, scheme, "/command", NULL);
        template = gconf_client_get_string (client, path, NULL);
[...]
        if (!g_shell_parse_argv (template,
                                 &argc,
                                 &argv,
                                 NULL)) {

which does the right thing with quotes if used in the gconf value. So, the root problem is that gnomevfs and python's webbrowser module interpret the string differently. I think it's safe to say that gnomevfs is more authoritative, and so the bug belongs to Python.

Matthias Klose (doko)
Changed in python2.5:
importance: Undecided → Low
Revision history for this message
Alexander Sack (asac) wrote :

priority low? doesn't this bug prevent users to get to proper bug report page?

Revision history for this message
Martin Pitt (pitti) wrote : Re: [Bug 83974] Re: webbrowser incorrectly handles quoted arguments for GNOME browser configuration

Alexander Sack [2007-03-07 17:17 -0000]:
> priority low? doesn't this bug prevent users to get to proper bug report
> page?

Apport falls back to the webbrowser module only in very special
circumstances now (Neither Gnome nor KDE are running, and Firefox is
not installed), and those are precisely the cases where webbrowser
failed, so it should not be a major concern from apport's POV.

Revision history for this message
Erik Meitner (e.meitner) wrote :

I had this problem also. I fixed it by changing my browser preferences in "Preferred Applications" from "Custom"(/usr/bin/firefox "%s") to "Firefox"(firefox %s).

Revision history for this message
Erik Meitner (e.meitner) wrote :

Adding to my previous note:
Once the change has been made, the next time Firefox is started it reports that it is not the default browser and asks if it should be made so. Selecting "Yes" sets the preferred browser config to "Custom: /usr/bin/firefox "%s" thus undoing the fix for this bug.

Revision history for this message
John Wiersba (jrw32982) wrote :

I submitted bug #113063 and was told that it was a duplicate of this one (#83974) and that it was fixed in feisty. However, I am running feisty with all updates applied (upgraded from edgy) but this bug still occurs.

Here's a copy of what I submitted in that other bug report:

Choose "Help > Report" a bug from firefox. After a few seconds, this pops up:

title: Problem loading page - Mozilla Firefox
text: File not found
   Firefox can't find the file at
   /home/jrw/"https://launchpad.net/ubuntu/+source/firefox/+filebug/jQZxWlghNh5hoDa0sWkYpl9JP1m?";.

I don't know what it's trying to do exactly, but this is an invalid filename.

Thank you!

Revision history for this message
grey (canisrogeris) wrote :

Same experience as John Wiersba, only I'm running a clean install of feisty with all updates applied. I have /home on a separate partition, so the bad Preferred Applications entry with the quotes stayed around until I stumbled on this tonight and fixed it manually. There may be a sizable group of people not reporting bugs because they don't realize they can modify the url. Any way of pushing a fix out automatically? In my experience very few people would go to the lengths necessary to find this thread and search it to find the solution.

Revision history for this message
Martin Pitt (pitti) wrote :

This still bites people, raising severity a bit.

Changed in python2.5:
importance: Low → Medium
Revision history for this message
Thomas Hotz (thotz-deactivatedaccount) wrote :

Martin: Is this bug still present in today's python packages?

Changed in python2.5 (Ubuntu):
status: Confirmed → Incomplete
Revision history for this message
Martin Pitt (pitti) wrote :

Let's close this old Python bug report. gnome-open has been obsolete for a long time (using gvfs-open now, and gsettings instead of gconf, etc.).

Changed in python2.5 (Ubuntu):
status: Incomplete → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.