From 04fcca7abd7556f98affc145647821b6dc4948b8 Mon Sep 17 00:00:00 2001 From: Robert Pluim Date: Tue, 10 Jun 2025 09:52:39 +0200 Subject: [PATCH] Normalize URL path correctly for http * lisp/url/url-http.el (url-http-create-request): Prepend "/" if it's missing from the filename. (Bug#78640) (cherry picked from commit 7e62c2cf3aadb52397bcff8439d00084cd36afa0) --- lisp/url/url-http.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el index 4258da33a33..eb5d5c13722 100644 --- a/lisp/url/url-http.el +++ b/lisp/url/url-http.el @@ -325,8 +325,10 @@ Use `url-http-referer' as the Referer-header (subject to `url-privacy-level')." url-http-target-url) nil 'any nil))) (ref-url (url-http--encode-string url-http-referer))) - (if (equal "" real-fname) - (setq real-fname "/")) + ;; RFC 3986 section 6.2.3 says an empty path should be normalized to + ;; "/", even if the filename is non-empty. (Bug#78640) + (unless (string-match-p "\\`/" real-fname) + (setq real-fname (concat "/" real-fname))) (setq no-cache (and no-cache (string-match "no-cache" no-cache))) (if auth (setq auth (concat "Authorization: " auth "\r\n"))) -- 2.39.5