Commit fdae50c7 authored by Ivan Shmakov's avatar Ivan Shmakov Committed by Lars Magne Ingebrigtsen
Browse files

shr URL expansion fixes

Fixes: debbugs:17958

* net/shr.el (shr-parse-base): Handle <base href=""> correctly.
(shr-expand-url): Expand absolute URLs correctly (bug#17958).
parent 584fa315
2014-11-13 Ivan Shmakov <ivan@siamics.net>
* net/shr.el (shr-parse-base): Handle <base href=""> correctly.
(shr-expand-url): Expand absolute URLs correctly (bug#17958).
2014-11-13 Lars Magne Ingebrigtsen <larsi@gnus.org>
* net/eww.el (eww): Add comment to clarify.
......
......@@ -594,6 +594,8 @@ size, and full-buffer size."
;; Always chop off anchors.
(when (string-match "#.*" url)
(setq url (substring url 0 (match-beginning 0))))
;; NB: <base href="" > URI may itself be relative to the document s URI
(setq url (shr-expand-url url))
(let* ((parsed (url-generic-parse-url url))
(local (url-filename parsed)))
(setf (url-filename parsed) "")
......@@ -616,6 +618,7 @@ size, and full-buffer size."
(defun shr-expand-url (url &optional base)
(setq base
(if base
;; shr-parse-base should never call this with non-nil base!
(shr-parse-base base)
;; Bound by the parser.
shr-base))
......@@ -624,8 +627,8 @@ size, and full-buffer size."
(cond ((or (not url)
(not base)
(string-match "\\`[a-z]*:" url))
;; Absolute URL.
(or url (car base)))
;; Absolute or empty URI
(or url (nth 3 base)))
((eq (aref url 0) ?/)
(if (and (> (length url) 1)
(eq (aref url 1) ?/))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment