]> git.eshelyaron.com Git - emacs.git/commitdiff
shr URL expansion fixes
authorIvan Shmakov <ivan@siamics.net>
Thu, 13 Nov 2014 18:41:20 +0000 (19:41 +0100)
committerLars Magne Ingebrigtsen <larsi@gnus.org>
Thu, 13 Nov 2014 18:41:20 +0000 (19:41 +0100)
Fixes: debbugs:17958
* net/shr.el (shr-parse-base): Handle <base href=""> correctly.
(shr-expand-url): Expand absolute URLs correctly (bug#17958).

lisp/ChangeLog
lisp/net/shr.el

index 0ad71f3963426c089e65653dfbcdee7e49fb66e3..652bc537ee5cde4985741fb4c0da7ac3217df20a 100644 (file)
@@ -1,3 +1,8 @@
+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.
index 7a5e2942d5da953e1a6ba8154b0dfd3f65f0aa17..cc90097102a8751d377d26e7bb553eb16974978d 100644 (file)
@@ -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) ?/))