emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-25 ba82d68: Follow <meta> redirects in eww


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] emacs-25 ba82d68: Follow <meta> redirects in eww
Date: Fri, 25 Dec 2015 19:52:18 +0000

branch: emacs-25
commit ba82d68819f2bc2b666f548fb76825f13b093dfa
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Follow <meta> redirects in eww
    
    Merge conflict, but I think I resolved it.
    
        Follow meta refresh tags in eww
    
        * eww.el (eww-tag-meta): Follow meta refresh tags (bug#22234).
    
    Backport:
---
 lisp/net/eww.el |   37 ++++++++++++++++++++++++++++++-------
 1 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/lisp/net/eww.el b/lisp/net/eww.el
index 29b4b87..033529d 100644
--- a/lisp/net/eww.el
+++ b/lisp/net/eww.el
@@ -407,13 +407,15 @@ Currently this means either text/html or 
application/xhtml+xml."
            (inhibit-modification-hooks t)
            (shr-target-id (url-target (url-generic-parse-url url)))
            (shr-external-rendering-functions
-            '((title . eww-tag-title)
-              (form . eww-tag-form)
-              (input . eww-tag-input)
-              (textarea . eww-tag-textarea)
-              (select . eww-tag-select)
-              (link . eww-tag-link)
-              (a . eww-tag-a))))
+             (append
+              '((title . eww-tag-title)
+                (form . eww-tag-form)
+                (input . eww-tag-input)
+                (textarea . eww-tag-textarea)
+                (select . eww-tag-select)
+                (link . eww-tag-link)
+                (meta . eww-tag-meta)
+                (a . eww-tag-a)))))
        (erase-buffer)
        (shr-insert-document document)
        (cond
@@ -458,6 +460,27 @@ Currently this means either text/html or 
application/xhtml+xml."
         where
         (plist-put eww-data (cdr where) href))))
 
+(defvar eww-redirect-level 1)
+
+(defun eww-tag-meta (dom)
+  (when (and (cl-equalp (dom-attr dom 'http-equiv) "refresh")
+             (< eww-redirect-level 5))
+    (when-let (refresh (dom-attr dom 'content))
+      (when (or (string-match "^\\([0-9]+\\) *;.*url=\"\\([^\"]+\\)\"" refresh)
+                (string-match "^\\([0-9]+\\) *;.*url=\\([^ ]+\\)" refresh))
+        (let ((timeout (match-string 1 refresh))
+              (url (match-string 2 refresh))
+              (eww-redirect-level (1+ eww-redirect-level)))
+          (if (equal timeout "0")
+              (eww (shr-expand-url url))
+            (eww-tag-a
+             (dom-node 'a `((href . ,(shr-expand-url url)))
+                       (format "Auto refresh in %s second%s disabled"
+                               timeout
+                               (if (equal timeout "1")
+                                   ""
+                                 "s"))))))))))
+
 (defun eww-tag-link (dom)
   (eww-handle-link dom)
   (shr-generic dom))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]