diff options
| author | Lars Ingebrigtsen | 2015-12-25 18:18:42 +0100 |
|---|---|---|
| committer | Lars Ingebrigtsen | 2015-12-25 18:18:42 +0100 |
| commit | bdaff9c813973c31dfe1cd357b0f5099ccd0b883 (patch) | |
| tree | 6038b730a0d54f67a6506f4770a75218b88bcbfc | |
| parent | a8627008abe4ab339df19b417776da28b3ce0fc7 (diff) | |
| download | emacs-bdaff9c813973c31dfe1cd357b0f5099ccd0b883.tar.gz emacs-bdaff9c813973c31dfe1cd357b0f5099ccd0b883.zip | |
Follow meta refresh tags in eww
* eww.el (eww-tag-meta): Follow meta refresh tags (bug#22234).
| -rw-r--r-- | lisp/net/eww.el | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lisp/net/eww.el b/lisp/net/eww.el index 593ed22dd38..742e1e4d1c0 100644 --- a/lisp/net/eww.el +++ b/lisp/net/eww.el | |||
| @@ -415,6 +415,7 @@ Currently this means either text/html or application/xhtml+xml." | |||
| 415 | (textarea . eww-tag-textarea) | 415 | (textarea . eww-tag-textarea) |
| 416 | (select . eww-tag-select) | 416 | (select . eww-tag-select) |
| 417 | (link . eww-tag-link) | 417 | (link . eww-tag-link) |
| 418 | (meta . eww-tag-meta) | ||
| 418 | (a . eww-tag-a))))) | 419 | (a . eww-tag-a))))) |
| 419 | (erase-buffer) | 420 | (erase-buffer) |
| 420 | (shr-insert-document document) | 421 | (shr-insert-document document) |
| @@ -460,6 +461,27 @@ Currently this means either text/html or application/xhtml+xml." | |||
| 460 | where | 461 | where |
| 461 | (plist-put eww-data (cdr where) href)))) | 462 | (plist-put eww-data (cdr where) href)))) |
| 462 | 463 | ||
| 464 | (defvar eww-redirect-level 1) | ||
| 465 | |||
| 466 | (defun eww-tag-meta (dom) | ||
| 467 | (when (and (cl-equalp (dom-attr dom 'http-equiv) "refresh") | ||
| 468 | (< eww-redirect-level 5)) | ||
| 469 | (when-let (refresh (dom-attr dom 'content)) | ||
| 470 | (when (or (string-match "^\\([0-9]+\\) *;.*url=\"\\([^\"]+\\)\"" refresh) | ||
| 471 | (string-match "^\\([0-9]+\\) *;.*url=\\([^ ]+\\)" refresh)) | ||
| 472 | (let ((timeout (match-string 1 refresh)) | ||
| 473 | (url (match-string 2 refresh)) | ||
| 474 | (eww-redirect-level (1+ eww-redirect-level))) | ||
| 475 | (if (equal timeout "0") | ||
| 476 | (eww (shr-expand-url url)) | ||
| 477 | (eww-tag-a | ||
| 478 | (dom-node 'a `((href . ,(shr-expand-url url))) | ||
| 479 | (format "Auto refresh in %s second%s disabled" | ||
| 480 | timeout | ||
| 481 | (if (equal timeout "1") | ||
| 482 | "" | ||
| 483 | "s")))))))))) | ||
| 484 | |||
| 463 | (defun eww-tag-link (dom) | 485 | (defun eww-tag-link (dom) |
| 464 | (eww-handle-link dom) | 486 | (eww-handle-link dom) |
| 465 | (shr-generic dom)) | 487 | (shr-generic dom)) |