Subject: [PATCH] Handle a case where url-basic-auth can crash

From: [email-masked]
Date: Sat, 11 Feb 2023 07:43:10 +0000

Hi all,

This seems like a simple patch, in cases where 
'url-request-noninteractive' is set and valid credentials either aren't 
found or the server sends 401 regardless (which is how I found this 
bug), this causes Emacs to crash.

I have copyright assignment assigned, even though this would fall under 
a "trivial change".

Thanks,
Ellis

From c35eddf8bc938ccfa0d9a55fc6f142595bc2de15 Mon Sep 17 00:00:00 2001
From: Ellis Kenyo <[email-masked]>
Date: Sat, 11 Feb 2023 07:27:56 +0000
Subject: [PATCH] Fix potential crash with url-basic-auth

* lisp/url/url-auth.el (url-basic-auth):
Handle a case where Emacs would crash where no valid credentials are found
and 'url-request-noninteractive' is t
---
 lisp/url/url-auth.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/url/url-auth.el b/lisp/url/url-auth.el
index e9ee72029f..83b4fa6468 100644
--- a/lisp/url/url-auth.el
+++ b/lisp/url/url-auth.el
@@ -100,7 +100,7 @@ instead of the filename inheritance method."
 			     (setq retval
 				   (base64-encode-string
 				    (format "%s:%s" user
-					    (encode-coding-string pass 'utf-8))
+					    (encode-coding-string (or pass "") 'utf-8))
                                     t))))
 		 (symbol-value url-basic-auth-storage))))
      (byserv
-- 
2.39.0