]> git.eshelyaron.com Git - emacs.git/commitdiff
url-parse.el: correct code for Windows paths (bug#76982)
authorSebastián Monía <sebastian@sebasmonia.com>
Mon, 28 Apr 2025 06:19:06 +0000 (08:19 +0200)
committerEshel Yaron <me@eshelyaron.com>
Tue, 29 Apr 2025 07:32:47 +0000 (09:32 +0200)
* lisp/url/url-parse.el (url-recreate-url): Handle empty filenames
without errors.

* test/lisp/url/url-parse-tests.el
(url-generic-parse-url/ms-windows-file-uri-hanlding): Add one
more test for the scenario above.

(cherry picked from commit bc5afe421b47ec31ce94ad8dc02912acd93c3319)

lisp/url/url-parse.el
test/lisp/url/url-parse-tests.el

index d2f49ef2c5ff9b42d1bda8fe73cfa0d83c910739..195cc957668c07d6eb9841e3b84f79fb8fde7143 100644 (file)
@@ -86,6 +86,7 @@ If the specified port number is the default, return nil."
          ;; For Windows/DOS-like paths, `url-generic-parse-url' strips
          ;; the leading /, so we need to add it back (bug#76982)
         (file (if (and (string= "file" type)
+                        (url-filename urlobj)
                         (string-match "^[A-Za-z]:[/\\]" (url-filename urlobj)))
                    (concat "/" (url-filename urlobj))
                  (url-filename urlobj)))
index c4c4b2fc8f8923c0da1ab5d3068f8616084068d0..66b27f3a638af1d630105858e7b1bf737d7d4f25 100644 (file)
   (should (equal (url-filename
                   (url-generic-parse-url "file:///c:\\directory\\file.txt"))
                  "c:\\directory\\file.txt"))
-  ;;
+  ;; paths with hostname = "localhost" should work too
   (should (equal (url-filename
                   (url-generic-parse-url "file://localhost/c:/path/to/file"))
-                 "c:/path/to/file")))
+                 "c:/path/to/file"))
+  ;; empty "file" url structs have to behave as they did before this fix
+  (should (equal (url-recreate-url
+                  (url-parse-make-urlobj "file" nil nil "myhost" nil
+                                         nil nil nil t))
+                 "file://myhost/")))
+
 
 (provide 'url-parse-tests)