GNU bug report logs -
#6339
url-filename => "/c:/some/file.txt"
Previous Next
Full log
Message #11 received at 6339 <at> debbugs.gnu.org (full text, mbox):
On Thu, Jun 3, 2010 at 04:38, Lennart Borgman <lennart.borgman <at> gmail.com> wrote:
> (setq x (url-generic-parse-url "file:///c:/some/file.txt"))
> (url-filename x) => "/c:/some/file.txt"
>
> Should not that be "c:/some/file.txt"?
This is caused by url-generic-parse-url thinking that in
file://HOST/PATH, the path is /PATH, when in fact, according to the
relevant RFCs, "/" is a separator and part of the URI syntax, and PATH
is an absolute path (to be interpreted as starting from / on Unix, but
that's irrelevant). This was extensively discussed in bug#5345.
The subyacent cause of the bug, IMHO, is that many software for POSIX
environments that parses URIs just takes the /PATH part as a whole
because it is easier than removing the slash and then re-adding it.
That breaks on Windows file: URIs, as this bug, and #5345, show.
So the right fix IMO is as simple as the attached patch. The problem
is that it will likely cause trouble for other users of
url-generic-parse-url which wrongly assume that the path part will be
rooted at /.
Another, hacky & ugly, fix is removing the slash only if the PATH part
matches /[A-Z]:.
I'd rather fix it the good way and watch the fireworks.
Juanma
=== modified file 'lisp/url/url-parse.el'
--- lisp/url/url-parse.el 2010-06-22 16:48:53 +0000
+++ lisp/url/url-parse.el 2010-07-26 11:46:11 +0000
@@ -148,4 +148,5 @@
;; 3.3. Path
+ (when (looking-at "/") (forward-char 1))
;; Gross hack to preserve ';' in data URLs
(setq save-pos (point))
This bug report was last modified 13 years and 17 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.