[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
w3m-url-fallback-base
- From: TSUCHIYA Masatoshi <tsuchiya@xxxxxxxxxx>
- Date: Wed, 19 Jul 2017 00:06:11 +0900
- X-ml-name: emacs-w3m
- X-mail-count: 12757
- References: <b4mwp769mgh.fsf@jpl.org>
>> On Tue, 18 Jul 2017 17:30:06 +0900
>> yamaoka@xxxxxxx (Katsumi Yamaoka) said as follows:
>Q1.
>========
>Why is the constant `w3m-url-fallback-base' "http:///", not
>"http://"? The function `w3m-expand-url' uses it and behaves as
>follows:
>(w3m-expand-url "www.gnu.org") => "http:///www.gnu.org"
>It is invalid. Shouldn't the result be "http://www.gnu.org"?
>--------
>なぜ定数 `w3m-url-fallback-base' は、"http://" ではなくて
>"http:///" なのですか? (w3m-expand-url "www.gnu.org") は
>"http:///www.gnu.org" を返しますが、無効な値です。その結果は
>"http://www.gnu.org" になるべきではないですか?
Well, I checked the revision when `w3m-url-fallback-base' was
introduced. It was w3m.el revision 1.416. And the change is attached
at the end of this message.
I also checked the archive of our ancient mailing list. I think this
change was introduced as the result of the discussion around
"[emacs-w3m:01656] w3m-expand-url".
And then, I reread the discussion and the code, finally, I think that
this default value has no technical ground. My suppose grounds to this
code:
(setq base (or w3m-current-base-url
w3m-current-url
w3m-url-fallback-base)))
This code means that `w3m-url-fallback-base' is simply used only when no
appropriate default value is given.
In other words, if the context gives another appropriate default value,
the context sholud set the default value to `w3m-current-base-url' or
`w3m-url-fallback-base', in my opinion.
--
TSUCHIYA Masatoshi
RCS file: /storage/cvsroot/emacs-w3m/w3m.el,v
retrieving revision 1.415
retrieving revision 1.416
diff -u -u -r1.415 -r1.416
--- w3m.el 10 Oct 2001 02:42:03 -0000 1.415
+++ w3m.el 10 Oct 2001 04:22:48 -0000 1.416
@@ -127,7 +127,7 @@
(defconst emacs-w3m-version
(eval-when-compile
- (let ((rev "$Revision: 1.415 $"))
+ (let ((rev "$Revision: 1.416 $"))
(and (string-match "\\.\\([0-9]+\\) \$$" rev)
(format "1.1.%d"
(- (string-to-number (match-string 1 rev)) 233)))))
@@ -1613,10 +1613,13 @@
'help-echo help
'balloon-help balloon))))
(name
- (when (re-search-forward "<\\|\n" nil t)
- (setq end (match-beginning 0))
+ (when (re-search-forward "[<\n]" nil t)
+ (goto-char (setq end (match-beginning 0)))
(when (= start end)
- (setq end (min (1+ end) (point-max))))
+ (setq end (min (if (looking-at "\\(<[^>]*>\\)+")
+ (1+ (match-end 0))
+ (1+ end))
+ (point-max))))
(w3m-add-text-properties start end
(list 'w3m-name-anchor name)))))))
(when w3m-next-url
@@ -2999,11 +3002,20 @@
refered in `w3m-expand-url' to keep backward compatibility which is
described in Section 5.2 of RFC 2396.")
+(defconst w3m-url-fallback-base "http:///")
+
(defun w3m-expand-url (url &optional base)
"Convert URL to absolute, and canonicalize it."
(save-match-data
- (unless base
- (setq base (or w3m-current-base-url w3m-current-url "")))
+ (if base
+ (unless (and (string-match w3m-url-components-regexp base)
+ (match-beginning 1)
+ (match-beginning 3))
+ (error "BASE must have a scheme part and a net-location part: %s"
+ base))
+ (setq base (or w3m-current-base-url
+ w3m-current-url
+ w3m-url-fallback-base)))
(string-match w3m-url-components-regexp url)
;; Remove an empty query part and an empty fragment part.
(or (and (match-beginning 6)
@@ -3023,7 +3035,7 @@
(let ((scheme (match-string 2 url)))
(if (and (member scheme w3m-url-hierarchical-schemes)
(string-match w3m-url-components-regexp base)
- (string= scheme (match-string 2 base)))
+ (equal scheme (match-string 2 base)))
(w3m-expand-url (substring url (match-end 1)) base)
url))))
((match-beginning 3)