[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: Toward emacs-w3m-1.4.1



>> On Fri, 25 Jun 2004 12:03:21 +0900
>> 「山」== yamaoka@jpl.org (Katsumi Yamaoka) said as follows:

山> [emacs-w3m : No.06925]

非常に適当なパッチなんですが,以下でどうでしょう.

または,w3m-browse-url() で不正な URI の入力(例えば,scheme を含まない)
を禁止するか.

;; ユーザー入力周辺は,だんだんスパゲッティ化してきて,とんでもなく分
;; かりにくくなってきてますねえ….

-- 
土屋 雅稔 ( TSUCHIYA Masatoshi )
--- w3m.el	25 Jun 2004 02:18:05 -0000	1.1019.2.17
+++ w3m.el	25 Jun 2004 03:24:07 -0000
@@ -3441,6 +3441,16 @@
 	(w3m-deactivate-region))
     (w3m-url-at-point)))
 
+(defsubst w3m-url-add-scheme (url)
+  (if (or (not (stringp url))
+	  (and (string-match w3m-url-components-regexp url)
+	       (match-beginning 1)))
+      url
+    (concat (if (and (file-name-absolute-p url) (file-exists-p url))
+		"file://"
+	      "http://";)
+	    url)))
+
 (defun w3m-input-url (&optional prompt initial default quick-start)
   "Read a url from the minibuffer, prompting with string PROMPT."
   (let (url)
@@ -3472,12 +3482,7 @@
       (when (stringp url)
 	(setq w3m-input-url-history
 	      (cons url (delete url w3m-input-url-history))))
-      ;; The return value of this function must contain a scheme part.
-      (if (or (not (stringp url))
-	      (and (string-match w3m-url-components-regexp url)
-		   (match-beginning 1)))
-	  url
-	(concat "http://"; url)))))
+      (w3m-url-add-scheme url))))
 
 
 ;;; Cache:
@@ -7380,6 +7385,7 @@
 		 (require 'browse-url)
 		 (browse-url-interactive-arg "Emacs-w3m URL: ")))
   (when (stringp url)
+    (setq url (w3m-url-add-scheme url))
     (if new-session
 	(w3m-goto-url-new-session url)
       (w3m-goto-url url))))