[emacs-w3m:10827] browse-url-of-file passes funny url to browser

Katsumi Yamaoka <[email protected]>
Newsgroups gmane.emacs.w3m,gmane.emacs.pretest.bugs
Organization Emacsen advocacy group
Message-ID <[email protected]>
Hi,

`browse-url-of-file' performed for a local file passes a funny
url to the browser.  So do `browse-url-of-dired-file' and
`browse-url-of-buffer'.  For instance:

(let* (result
       (browse-url-browser-function (lambda (url &optional arg)
				      (setq result url))))
  (browse-url-of-file "/some/where/index.html")
  result)
 => "file:/some/where/index.html"

Some browsers (e.g. Firefox) work with such a url but others
(e.g. emacs-w3m) don't.  It is due to the last item of the default
value of `browse-url-filename-alist':

--8<---------------cut here---------------start------------->8---
browse-url-filename-alist is a variable defined in `browse-url.el'.
Its value is
(("^/\\(ftp@\\|anonymous@\\)?\\([^:]+\\):/*" . "ftp://\\2/")
 ("^/\\([^:@]+@\\)?\\([^:]+\\):/*" . "ftp://\\1\\2/")
 ("^/+" . "file:/"))
--8<---------------cut here---------------end--------------->8---

I believe it should be ("^/+" . "file:///").  Does anyone know
any harm with this change?

--8<---------------cut here---------------start------------->8---
*** browse-url.el~	Mon Jan  5 03:22:43 2009
--- browse-url.el	Tue Apr 14 10:57:43 2009
***************
*** 446,452 ****
      ,@(if (memq system-type '(windows-nt ms-dos cygwin))
            '(("^\\([a-zA-Z]:\\)[\\/]" . "file:\\1/")
              ("^[\\/][\\/]+" . "file://")))
!     ("^/+" . "file:/"))
    "An alist of (REGEXP . STRING) pairs used by `browse-url-of-file'.
  Any substring of a filename matching one of the REGEXPs is replaced by
  the corresponding STRING using `replace-match', not treating STRING
--- 446,452 ----
      ,@(if (memq system-type '(windows-nt ms-dos cygwin))
            '(("^\\([a-zA-Z]:\\)[\\/]" . "file:\\1/")
              ("^[\\/][\\/]+" . "file://")))
!     ("^/+" . "file:///"))
    "An alist of (REGEXP . STRING) pairs used by `browse-url-of-file'.
  Any substring of a filename matching one of the REGEXPs is replaced by
  the corresponding STRING using `replace-match', not treating STRING
--8<---------------cut here---------------end--------------->8---

Regards,
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.