]> git.eshelyaron.com Git - emacs.git/commitdiff
Make nndoc more resilient against corrupted files
authorLars Ingebrigtsen <larsi@gnus.org>
Thu, 26 Jan 2017 21:28:17 +0000 (22:28 +0100)
committerLars Ingebrigtsen <larsi@gnus.org>
Thu, 26 Jan 2017 21:28:17 +0000 (22:28 +0100)
* lisp/gnus/nndoc.el (nndoc-possibly-change-buffer): Don't bug
out on invalid files, like invalid .gz files (bug#21538).
This may hinder Gnus from starting up.

lisp/gnus/nndoc.el

index ede118d6eb660d0663d98a9948464f541b785a3f..7f7db8721db8dbf3b8a73eaba7b330e100956b9a 100644 (file)
@@ -356,14 +356,18 @@ from the document.")
       (setq nndoc-dissection-alist nil)
       (with-current-buffer nndoc-current-buffer
        (erase-buffer)
-       (if (and (stringp nndoc-address)
-                (string-match nndoc-binary-file-names nndoc-address))
-           (let ((coding-system-for-read 'binary))
-             (mm-insert-file-contents nndoc-address))
-         (if (stringp nndoc-address)
-             (nnheader-insert-file-contents nndoc-address)
-           (insert-buffer-substring nndoc-address))
-         (run-hooks 'nndoc-open-document-hook)))))
+       (condition-case error
+           (if (and (stringp nndoc-address)
+                    (string-match nndoc-binary-file-names nndoc-address))
+               (let ((coding-system-for-read 'binary))
+                 (mm-insert-file-contents nndoc-address))
+             (if (stringp nndoc-address)
+                 (nnheader-insert-file-contents nndoc-address)
+               (insert-buffer-substring nndoc-address))
+             (run-hooks 'nndoc-open-document-hook))
+         (file-error
+          (nnheader-report 'nndoc "Couldn't open %s: %s"
+                           group error))))))
     ;; Initialize the nndoc structures according to this new document.
     (when (and nndoc-current-buffer
               (not nndoc-dissection-alist))