From 384504edf35751eec2be9b52be5d3b250217d68f Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Wed, 11 Jan 2023 09:27:01 +0100 Subject: [PATCH] Ensure VC package names are not empty * lisp/emacs-lisp/package-vc.el (package-vc--unpack): Raise an error if the package name is empty. (package-vc-install): Avoid generating an empty file name, if a URL ends with a slash, and raise an error if the package name is empty. --- lisp/emacs-lisp/package-vc.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index ba1a01faeee..b5b8a6746a6 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el @@ -606,6 +606,8 @@ checkout. This overrides the `:branch' attribute in PKG-SPEC." (name (package-desc-name pkg-desc)) (dirname (package-desc-full-name pkg-desc)) (pkg-dir (expand-file-name dirname package-user-dir))) + (when (string-empty-p name) + (user-error "Empty package name")) (setf (package-desc-dir pkg-desc) pkg-dir) (when (file-exists-p pkg-dir) (if (yes-or-no-p (format "Overwrite previous checkout for package `%s'?" name)) @@ -773,7 +775,9 @@ regular package, but it will not remove a VC package. (package-vc--archives-initialize) (let* ((name-or-url (package-vc--read-package-name "Fetch and install package: " t)) - (name (file-name-base name-or-url))) + (name (file-name-base (directory-file-name name-or-url)))) + (when (string-empty-p name) + (user-error "Empty package name")) (list name-or-url (and current-prefix-arg :last-release) nil -- 2.39.2