Follow refresh url.
[gnus] / lisp / nnweb.el
index 1a6fab5..36047f5 100644 (file)
@@ -745,10 +745,23 @@ and `altavista'.")
   (while (re-search-forward "<[^>]+>" nil t)
     (replace-match "" t t)))
 
-(defun nnweb-insert (url)
-  "Insert the contents from an URL in the current buffer."
+(defun nnweb-insert (url &optional follow-refresh)
+  "Insert the contents from an URL in the current buffer.
+If FOLLOW-REFRESH is non-nil, redirect refresh url in META."
   (let ((name buffer-file-name))
-    (url-insert-file-contents url)
+    (if follow-refresh
+       (save-restriction
+         (url-insert-file-contents url)
+         (goto-char (point-min))
+         (while (re-search-forward 
+                 "HTTP-EQUIV=\"Refresh\"[^>]*URL=\\([^\"]+\\)\""
+                 nil t)
+           (let ((url (match-string 1)))
+             (delete-region (point-min) (point-max))
+             (nnweb-insert url))
+           (goto-char (point-min)))
+         (goto-char (point-max)))
+      (url-insert-file-contents url))
     (setq buffer-file-name name)))
 
 (defun nnweb-parse-find (type parse &optional maxdepth)