]> git.eshelyaron.com Git - emacs.git/commitdiff
Don't try to add nil packages on refresh
authorStefan Kangas <stefankangas@gmail.com>
Sun, 20 Oct 2019 21:49:18 +0000 (23:49 +0200)
committerStefan Kangas <stefankangas@gmail.com>
Sun, 20 Oct 2019 22:00:36 +0000 (00:00 +0200)
* lisp/emacs-lisp/package.el (package-read-archive-contents): Don't
try to add nil entries.  Warn instead.  (Bug#28502)
* test/lisp/emacs-lisp/package-tests.el
(package-test-update-archives/ignore-nil-entry): New test.
* test/lisp/emacs-lisp/package-resources/with-nil-entry/archive-contents:
New file.

lisp/emacs-lisp/package.el
test/lisp/emacs-lisp/package-resources/with-nil-entry/archive-contents [new file with mode: 0644]
test/lisp/emacs-lisp/package-tests.el

index 20462064afd800911cf698656c898973593f1824..645e831bcc957c753511b126c5cbe01c25bf561c 100644 (file)
@@ -1520,7 +1520,10 @@ If the archive version is too new, signal an error."
          (contents (package--read-archive-file contents-file)))
     (when contents
       (dolist (package contents)
-        (package--add-to-archive-contents package archive)))))
+        (if package
+            (package--add-to-archive-contents package archive)
+          (lwarn '(package refresh) :warning
+                 "Ignoring `nil' package on `%s' package archive" archive))))))
 
 (defvar package--old-archive-priorities nil
   "Store currently used `package-archive-priorities'.
diff --git a/test/lisp/emacs-lisp/package-resources/with-nil-entry/archive-contents b/test/lisp/emacs-lisp/package-resources/with-nil-entry/archive-contents
new file mode 100644 (file)
index 0000000..03e6aa7
--- /dev/null
@@ -0,0 +1,8 @@
+(1
+ (foo .
+      [(1 0)
+      nil "foo package" single])
+ nil
+ (bar .
+      [(1 0)
+      nil "bar package" single]))
index 8670e6f3fac87e4e3f980f6f8a88fbbf27b85d58..828c456842a19cb977101ada42cc3889e81f3657 100644 (file)
@@ -452,6 +452,16 @@ Must called from within a `tar-mode' buffer."
              (search-forward-regexp "^ +simple-single" nil t))))
       (if (process-live-p process) (kill-process process)))))
 
+(ert-deftest package-test-update-archives/ignore-nil-entry ()
+  "Ignore any packages that are nil.  Test for Bug#28502."
+  (with-package-test ()
+    (let* ((with-nil-entry (expand-file-name "package-resources/with-nil-entry"
+                                             package-test-file-dir))
+           (package-archives `(("with-nil-entry" . ,with-nil-entry))))
+      (package-initialize)
+      (package-refresh-contents)
+      (should (equal (length package-archive-contents) 2)))))
+
 (ert-deftest package-test-describe-package ()
   "Test displaying help for a package."