diff options
| author | Ivan Shmakov | 2014-11-13 19:41:20 +0100 |
|---|---|---|
| committer | Lars Magne Ingebrigtsen | 2014-11-13 19:41:20 +0100 |
| commit | fdae50c73f22ec73a5159986b9c65624a3c4cd67 (patch) | |
| tree | 8aa91f97abf71d97f0e341327afed2a4b26b256d /lisp | |
| parent | 584fa315db2c041f0e05a9d709c3ee03c7f91be2 (diff) | |
| download | emacs-fdae50c73f22ec73a5159986b9c65624a3c4cd67.tar.gz emacs-fdae50c73f22ec73a5159986b9c65624a3c4cd67.zip | |
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).
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | 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 @@ | |||
| 1 | 2014-11-13 Ivan Shmakov <ivan@siamics.net> | ||
| 2 | |||
| 3 | * net/shr.el (shr-parse-base): Handle <base href=""> correctly. | ||
| 4 | (shr-expand-url): Expand absolute URLs correctly (bug#17958). | ||
| 5 | |||
| 1 | 2014-11-13 Lars Magne Ingebrigtsen <larsi@gnus.org> | 6 | 2014-11-13 Lars Magne Ingebrigtsen <larsi@gnus.org> |
| 2 | 7 | ||
| 3 | * net/eww.el (eww): Add comment to clarify. | 8 | * 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." | |||
| 594 | ;; Always chop off anchors. | 594 | ;; Always chop off anchors. |
| 595 | (when (string-match "#.*" url) | 595 | (when (string-match "#.*" url) |
| 596 | (setq url (substring url 0 (match-beginning 0)))) | 596 | (setq url (substring url 0 (match-beginning 0)))) |
| 597 | ;; NB: <base href="" > URI may itself be relative to the document s URI | ||
| 598 | (setq url (shr-expand-url url)) | ||
| 597 | (let* ((parsed (url-generic-parse-url url)) | 599 | (let* ((parsed (url-generic-parse-url url)) |
| 598 | (local (url-filename parsed))) | 600 | (local (url-filename parsed))) |
| 599 | (setf (url-filename parsed) "") | 601 | (setf (url-filename parsed) "") |
| @@ -616,6 +618,7 @@ size, and full-buffer size." | |||
| 616 | (defun shr-expand-url (url &optional base) | 618 | (defun shr-expand-url (url &optional base) |
| 617 | (setq base | 619 | (setq base |
| 618 | (if base | 620 | (if base |
| 621 | ;; shr-parse-base should never call this with non-nil base! | ||
| 619 | (shr-parse-base base) | 622 | (shr-parse-base base) |
| 620 | ;; Bound by the parser. | 623 | ;; Bound by the parser. |
| 621 | shr-base)) | 624 | shr-base)) |
| @@ -624,8 +627,8 @@ size, and full-buffer size." | |||
| 624 | (cond ((or (not url) | 627 | (cond ((or (not url) |
| 625 | (not base) | 628 | (not base) |
| 626 | (string-match "\\`[a-z]*:" url)) | 629 | (string-match "\\`[a-z]*:" url)) |
| 627 | ;; Absolute URL. | 630 | ;; Absolute or empty URI |
| 628 | (or url (car base))) | 631 | (or url (nth 3 base))) |
| 629 | ((eq (aref url 0) ?/) | 632 | ((eq (aref url 0) ?/) |
| 630 | (if (and (> (length url) 1) | 633 | (if (and (> (length url) 1) |
| 631 | (eq (aref url 1) ?/)) | 634 | (eq (aref url 1) ?/)) |