From fdae50c73f22ec73a5159986b9c65624a3c4cd67 Mon Sep 17 00:00:00 2001 From: Ivan Shmakov Date: Thu, 13 Nov 2014 19:41:20 +0100 Subject: [PATCH] shr URL expansion fixes Fixes: debbugs:17958 * net/shr.el (shr-parse-base): Handle correctly. (shr-expand-url): Expand absolute URLs correctly (bug#17958). --- lisp/ChangeLog | 5 +++++ lisp/net/shr.el | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 0ad71f39634..652bc537ee5 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2014-11-13 Ivan Shmakov + + * net/shr.el (shr-parse-base): Handle correctly. + (shr-expand-url): Expand absolute URLs correctly (bug#17958). + 2014-11-13 Lars Magne Ingebrigtsen * net/eww.el (eww): Add comment to clarify. diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 7a5e2942d5d..cc90097102a 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -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: 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) ?/)) -- 2.39.5