Subject: bug#5362: 23.1.91; browse-url-of-dired-file vs. files::with::colons

From: Lars Ingebrigtsen <[email-masked]>
Date: Fri, 25 Dec 2015 23:15:08 +0100

[email-masked] writes:

> b runs the command browse-url-of-dired-file
> And when used on
> /tmp/WWW::Facebook::API.html
> it tried to browse
> ftp://tmp/WWW/:Facebook::API.html
>
> Say, aren't files always local files?

They are, so this is pretty nonsensical.

The culprit here is

(defun browse-url-file-url (file)
  "Return the URL corresponding to FILE.
Use variable `browse-url-filename-alist' to map filenames to URLs."
  (let ((coding (if (equal system-type 'windows-nt)
		    ;; W32 pretends that file names are UTF-8 encoded.
		    'utf-8
		  (and (default-value 'enable-multibyte-characters)
		       (or file-name-coding-system
			   default-file-name-coding-system)))))
    (if coding (setq file (encode-coding-string file coding))))
  (setq file (browse-url-url-encode-chars file "[*\"()',=;?% ]"))
  (dolist (map browse-url-filename-alist)
    (when (and map (string-match (car map) file))
      (setq file (replace-match (cdr map) t nil file))))
  file)

(browse-url-file-url "/tmp/WWW::Facebook::API.html")
=> "ftp://tmp/WWW/:Facebook::API.html"

Which is wrong.

I don't quite understand why it does all this?  Why doesn't it just
prepend "file://" to the file name?  (Ok, it should probably do the
browse-url-url-encode-chars thing, anyway...)

Ideas?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no