xdg-open of a file-scheme URL containing blanks

Bug #951739 reported by SegundoBob
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
leo-editor
Fix Released
Low
Edward K. Ream

Bug Description

The major problem is that currently blanks are not allowed in file-scheme URL's.
The minor problem is that error messages are printed on the console.

When an attempt is made to open a file-scheme URL that contains blanks (making it an invalid URL), an error message like the following is printed on the console:

xdg-open: unexpected argument 'Dodge'
Try 'xdg-open --help' for more information.
--- Error message end ----

The URL that caused the above message:
file:///media/datw1/BobH/0/2002 Dodge Neon SXT/Dodge Dealers.txt

Fix to both problems:
Either single or double quotations are needed around the pathname that is passed to xdg-open.

Test System:
Ubuntu 11.10 with Fluxbox window manager
Leo Log Window
Leo 4.9.1 devel, build 5106, 2012-03-09 19:20:49
Python 2.7.2, qt version 4.7.3
linux2
setting leoID from os.getenv('USER'): 'bob'
load dir: /home/bob/bzr/LeoLatest/leo/core
global config dir: /home/bob/bzr/LeoLatest/leo/config
home dir: /home/bob
reading settings in /home/bob/bzr/LeoLatest/leo/config/leoSettings.leo
reading settings in /home/bob/.leo/myLeoSettings.leo
reading settings in /media/datw1/BobH/1/Leo/Leo.leo

Revision history for this message
SegundoBob (bhossley) wrote :

Ideally, Leo-Editor would require a valid URL in this case. That is, a URL with the blanks escaped as specified by the URL standard. This requires Leo-Editor to remove the HTML escapes and enclose the pathname in quotations before passing it to xdg-open.

I believe the library function urllib.unquote(string) will put the blanks back.

Revision history for this message
Edward K. Ream (edreamleo) wrote : Re: [Bug 951739] [NEW] xdg-open of a file-scheme URL containing blanks

On Sat, Mar 10, 2012 at 1:15 PM, SegundoBob <email address hidden> wrote:

> The major problem is that currently blanks are not allowed in file-scheme URL's. The minor problem is that error messages are printed on the console.

Thanks for this report. I'll fix the problems shortly.

Edward

Changed in leo-editor:
milestone: none → 4.10-b1
importance: Undecided → Low
assignee: nobody → Edward K. Ream (edreamleo)
Revision history for this message
Edward K. Ream (edreamleo) wrote :

Fixed at rev 5121. Tested (by hand) on both Windows and Ubuntu.

Changed in leo-editor:
status: New → Fix Released
Revision history for this message
SegundoBob (bhossley) wrote :

Your fix works--but, it leaves something to be desired.

Your fix only works for non-standard URL's that contain blanks. That is, they are not valid URL's according to the URL standard. Such URL's are not properly colored as URL's. The URL coloring stops before the first blank.

You could allow both standard URL's and pseudo-URL's containing blanks by running all file-scheme URL's through urllib.unquote() before passing them to xdg-open

Python Interpreter console:
>>> import urllib
>>> s1 = 'file:///media/datw1/BobH/0/2002%20Dodge%20Neon%20SXT/Dodge%20Dealers.txt'
>>> s2 = 'file:///media/datw1/BobH/0/2002 Dodge Neon SXT/Dodge Dealers.txt'
>>> urllib.unquote(s1)
'file:///media/datw1/BobH/0/2002 Dodge Neon SXT/Dodge Dealers.txt'
>>> urllib.unquote(s2)
'file:///media/datw1/BobH/0/2002 Dodge Neon SXT/Dodge Dealers.txt'
--- End Python Interpreter console ---

Test System:
Ubuntu 11.10 with Fluxbox window manager
Leo Log Window
Leo 4.9.1 devel, build 5121, 2012-03-11 15:35:03
Python 2.7.2, qt version 4.7.3
linux2
setting leoID from os.getenv('USER'): 'bob'
load dir: /home/bob/bzr/LeoLatest/leo/core
global config dir: /home/bob/bzr/LeoLatest/leo/config
home dir: /home/bob
reading settings in /home/bob/bzr/LeoLatest/leo/config/leoSettings.leo
reading settings in /home/bob/.leo/myLeoSettings.leo
reading settings in /home/bob/.leo/workbook.leo

Revision history for this message
Edward K. Ream (edreamleo) wrote : Re: [Bug 951739] Re: xdg-open of a file-scheme URL containing blanks

On Sun, Mar 11, 2012 at 6:31 PM, SegundoBob <email address hidden> wrote:

> You could allow both standard URL's and pseudo-URL's containing blanks
> by running all file-scheme URL's through urllib.unquote() before passing
> them to xdg-open

Will do. I missed your earlier suggestion to use urllib.unquote.

EKR

Revision history for this message
Edward K. Ream (edreamleo) wrote :

On Mon, Mar 12, 2012 at 7:04 AM, Edward K. Ream <email address hidden> wrote:
> On Sun, Mar 11, 2012 at 6:31 PM, SegundoBob <email address hidden> wrote:
>
>> You could allow both standard URL's and pseudo-URL's containing blanks
>> by running all file-scheme URL's through urllib.unquote() before passing
>> them to xdg-open
>
> Will do.  I missed your earlier suggestion to use urllib.unquote.

Done at rev 5127. This is a one-line change to g.handleUrl. Let me
know if there are further problems. I'd like to wrap this up
completely today.

Edward

Revision history for this message
SegundoBob (bhossley) wrote :

There are problems with your latest change: 1) For me it does not do what it was intended to do. 2) For me, it (or some other change in this area), changes an http: URL into a file: URL.

The file-scheme URL with blanks still works. For example for me:

file:///media/datw1/BobH/0/2002 Dodge Neon SXT/Dodge Dealers.txt

I ran the above through urllib.quote() to get:

file:///media/datw1/BobH/0/2002%20Dodge%20Neon%20SXT/Dodge%20Dealers.txt

But the "quoted" URL still fails with this message in the Log pane:

File '/media/datw1/BobH/0/2002%20Dodge%20Neon%20SXT/Dodge%20Dealers.txt' does not exist

What is worse, is that now double-click-icon-box with a URL :

https://bugs.launchpad.net/leo-editor/+bug/951739

Now calls the default browser to open URL:

file:///leo-editor/+bug/951739

urllib.unquote() does NOT change https://bugs.launchpad.net/leo-editor/+bug/951739 so something else is changing it.

Test System:
Ubuntu 11.10 with Fluxbox window manager
Leo Log Window
Leo 4.9.1 devel, build 5128, 2012-03-12 08:55:37
Python 2.7.2, qt version 4.7.3
linux2
setting leoID from os.getenv('USER'): 'bob'
load dir: /home/bob/bzr/LeoLatest/leo/core
global config dir: /home/bob/bzr/LeoLatest/leo/config
home dir: /home/bob
reading settings in /home/bob/bzr/LeoLatest/leo/config/leoSettings.leo
reading settings in /home/bob/.leo/myLeoSettings.leo
reading settings in /home/bob/.leo/workbook.leo
reading: /home/bob/.leo/workbook.leo

Revision history for this message
Edward K. Ream (edreamleo) wrote :

On Mon, Mar 12, 2012 at 11:16 AM, SegundoBob <email address hidden> wrote:
> There are problems with your latest change:  1) For me it does not do
> what it was intended to do.  2) For me, it (or some other change in this
> area), changes an http: URL into a file: URL.

Rev 5130 fixes 2).

Edward

Revision history for this message
SegundoBob (bhossley) wrote :

Prior Problem :
2) An http: URL is changed into a file: URL.

2) Has been fixed for me also.
1) Is unchanged: URL's with escaped blanks don't work.

Test System:
Ubuntu 11.10 with Fluxbox window manager

Leo Log Window
Leo 4.9.1 devel, build 5130, 2012-03-12 12:44:36
Python 2.7.2, qt version 4.7.3
linux2
setting leoID from os.getenv('USER'): 'bob'
load dir: /home/bob/bzr/LeoLatest/leo/core
global config dir: /home/bob/bzr/LeoLatest/leo/config
home dir: /home/bob
reading settings in /home/bob/bzr/LeoLatest/leo/config/leoSettings.leo
reading settings in /home/bob/.leo/myLeoSettings.leo
reading settings in /media/datw1/BobH/1/Leo/Leo.leo
reading: /media/datw1/BobH/1/Leo/Leo.leo

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.