]> git.eshelyaron.com Git - emacs.git/commitdiff
Normalize URL path correctly for http
authorRobert Pluim <rpluim@gmail.com>
Tue, 10 Jun 2025 07:52:39 +0000 (09:52 +0200)
committerEshel Yaron <me@eshelyaron.com>
Wed, 18 Jun 2025 08:10:57 +0000 (10:10 +0200)
* 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

index 4258da33a336a45fc547e45e7b4f6b9a11f2eaa0..eb5d5c13722d24591cdbfaeed944a964219dba64 100644 (file)
@@ -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")))