unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#54721: 29.0.50; browse-url-file-url fails on Windows since e06319b
@ 2022-04-05  6:57 Kiên Nguyễn Quang
       [not found] ` <handler.54721.B.164914187929306.ack@debbugs.gnu.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Kiên Nguyễn Quang @ 2022-04-05  6:57 UTC (permalink / raw)
  To: 54721

[-- Attachment #1: Type: text/plain, Size: 483 bytes --]

Error:
*(error "ShellExecute failed: The system cannot find the file specified.")*

It's because e06319b is using `file-name-split` which will discard the
driver name in Windows.
For example:
(file-name-split "c:/Data/projects/notes/techs/.burlIU3pav.html")
# Output: ("" "Data" "projects" "notes" "techs" ".burlIU3pav.html")

Since the driver name is discarded, the constructed URL is
"file:///Data/projects/notes/techs/.burlIU3pav.html", which does not
exist and cannot be opened.

[-- Attachment #2: Type: text/html, Size: 825 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#54721: Acknowledgement (29.0.50; browse-url-file-url fails on Windows since e06319b)
       [not found] ` <handler.54721.B.164914187929306.ack@debbugs.gnu.org>
@ 2022-04-06  0:30   ` Kiên Nguyễn Quang
  2022-04-06  5:39     ` Kiên Nguyễn Quang
  0 siblings, 1 reply; 4+ messages in thread
From: Kiên Nguyễn Quang @ 2022-04-06  0:30 UTC (permalink / raw)
  To: 54721


[-- Attachment #1.1: Type: text/plain, Size: 987 bytes --]

The proposed fix is attached.

On Tue, Apr 5, 2022 at 3:58 PM GNU bug Tracking System <help-debbugs@gnu.org>
wrote:

> Thank you for filing a new bug report with debbugs.gnu.org.
>
> This is an automatically generated reply to let you know your message
> has been received.
>
> Your message is being forwarded to the package maintainers and other
> interested parties for their attention; they will reply in due course.
>
> Your message has been sent to the package maintainer(s):
>  bug-gnu-emacs@gnu.org
>
> If you wish to submit further information on this problem, please
> send it to 54721@debbugs.gnu.org.
>
> Please do not send mail to help-debbugs@gnu.org unless you wish
> to report a problem with the Bug-tracking system.
>
> --
> 54721: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=54721
> GNU Bug Tracking System
> Contact help-debbugs@gnu.org with problems
>


-- 
 Nguyen Quang Kien - グエン クアン キエン
 Software Developer @ MSD

[-- Attachment #1.2: Type: text/html, Size: 1934 bytes --]

[-- Attachment #2: 0001-Make-file-name-split-returns-driver-name-as-well-in-.patch --]
[-- Type: application/octet-stream, Size: 879 bytes --]

From f4e30b839a02c2518688306bc213278f75d19a95 Mon Sep 17 00:00:00 2001
From: Kien Nguyen <kien.n.quang@gmail.com>
Date: Wed, 6 Apr 2022 09:21:32 +0900
Subject: [PATCH] Make file-name-split returns driver name as well in Windows

* lisp/files.el: make file-name-split returns driver name as well in Windows (bug#54721)

---
 lisp/files.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/files.el b/lisp/files.el
index a0bc5bf262..c198f18723 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -5091,7 +5091,7 @@ file-name-split
         ;; If there's nothing left to peel off, we're at the root and
         ;; we can stop.
         (when (and dir (equal dir filename))
-          (push "" components)
+          (push (if (string-empty-p dir) "" (substring dir 0 -1)) components)
           (setq filename nil))))
     components))
 
-- 
2.35.1.windows.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#54721: Acknowledgement (29.0.50; browse-url-file-url fails on Windows since e06319b)
  2022-04-06  0:30   ` bug#54721: Acknowledgement (29.0.50; browse-url-file-url fails on Windows since e06319b) Kiên Nguyễn Quang
@ 2022-04-06  5:39     ` Kiên Nguyễn Quang
  2022-04-06  9:59       ` bug#54721: 29.0.50; browse-url-file-url fails on Windows since e06319b Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Kiên Nguyễn Quang @ 2022-04-06  5:39 UTC (permalink / raw)
  To: 54721


[-- Attachment #1.1: Type: text/plain, Size: 1044 bytes --]

Update patch.

On Wed, Apr 6, 2022 at 9:30 AM Kiên Nguyễn Quang <kien.n.quang@gmail.com>
wrote:

> The proposed fix is attached.
>
> On Tue, Apr 5, 2022 at 3:58 PM GNU bug Tracking System <
> help-debbugs@gnu.org> wrote:
>
>> Thank you for filing a new bug report with debbugs.gnu.org.
>>
>> This is an automatically generated reply to let you know your message
>> has been received.
>>
>> Your message is being forwarded to the package maintainers and other
>> interested parties for their attention; they will reply in due course.
>>
>> Your message has been sent to the package maintainer(s):
>>  bug-gnu-emacs@gnu.org
>>
>> If you wish to submit further information on this problem, please
>> send it to 54721@debbugs.gnu.org.
>>
>> Please do not send mail to help-debbugs@gnu.org unless you wish
>> to report a problem with the Bug-tracking system.
>>
>> --
>> 54721: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=54721
>> GNU Bug Tracking System
>> Contact help-debbugs@gnu.org with problems
>>
>
>
>

[-- Attachment #1.2: Type: text/html, Size: 2061 bytes --]

[-- Attachment #2: 0001-Make-file-name-split-returns-driver-name-as-well-in-.patch --]
[-- Type: application/octet-stream, Size: 1873 bytes --]

From 573f0ecb29000ad70dc04fcabd9fa45744ade9f3 Mon Sep 17 00:00:00 2001
From: Kien Nguyen <kien.n.quang@gmail.com>
Date: Wed, 6 Apr 2022 09:21:32 +0900
Subject: [PATCH] Make file-name-split returns driver name as well in Windows

* lisp/files.el (file-name-split): returns driver name as well in Windows
  lisp/net/browse-url.el (browse-url-file-url): dont hexify colon character in file path for Windows (bug#54721)

---
 lisp/files.el          | 2 +-
 lisp/net/browse-url.el | 7 ++++---
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index a0bc5bf262..c198f18723 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -5091,7 +5091,7 @@ file-name-split
         ;; If there's nothing left to peel off, we're at the root and
         ;; we can stop.
         (when (and dir (equal dir filename))
-          (push "" components)
+          (push (if (string-empty-p dir) "" (substring dir 0 -1)) components)
           (setq filename nil))))
     components))
 
diff --git a/lisp/net/browse-url.el b/lisp/net/browse-url.el
index 4c348781a8..0fbf2d40f4 100644
--- a/lisp/net/browse-url.el
+++ b/lisp/net/browse-url.el
@@ -728,9 +728,10 @@ browse-url-file-url
                      browse-url-filename-alist))
       (setq file (browse-url-url-encode-chars file "[*\"()',=;?% ]"))
     ;; Encode all other file names properly.
-    (setq file (mapconcat #'url-hexify-string
-                          (file-name-split file)
-                          "/")))
+    (let ((url-unreserved-chars `(?: ,@url-unreserved-chars)))
+      (setq file (mapconcat #'url-hexify-string
+                            (file-name-split file)
+                            "/"))))
   (dolist (map browse-url-filename-alist)
     (when (and map (string-match (car map) file))
       (setq file (replace-match (cdr map) t nil file))))
-- 
2.35.1.windows.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* bug#54721: 29.0.50; browse-url-file-url fails on Windows since e06319b
  2022-04-06  5:39     ` Kiên Nguyễn Quang
@ 2022-04-06  9:59       ` Lars Ingebrigtsen
  0 siblings, 0 replies; 4+ messages in thread
From: Lars Ingebrigtsen @ 2022-04-06  9:59 UTC (permalink / raw)
  To: Kiên Nguyễn Quang; +Cc: 54721

Kiên Nguyễn Quang <kien.n.quang@gmail.com> writes:

> -          (push "" components)
> +          (push (if (string-empty-p dir) "" (substring dir 0 -1)) components)

Thanks; applied with some changes.

> +    (let ((url-unreserved-chars `(?: ,@url-unreserved-chars)))
> +      (setq file (mapconcat #'url-hexify-string
> +                            (file-name-split file)
> +                            "/"))))

This isn't quite correct, because we do want to encode : characters in
file names in general -- just not the first bit on Windows.  So I've
adjusted the patch and pushed to Emacs 29.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-06  9:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-05  6:57 bug#54721: 29.0.50; browse-url-file-url fails on Windows since e06319b Kiên Nguyễn Quang
     [not found] ` <handler.54721.B.164914187929306.ack@debbugs.gnu.org>
2022-04-06  0:30   ` bug#54721: Acknowledgement (29.0.50; browse-url-file-url fails on Windows since e06319b) Kiên Nguyễn Quang
2022-04-06  5:39     ` Kiên Nguyễn Quang
2022-04-06  9:59       ` bug#54721: 29.0.50; browse-url-file-url fails on Windows since e06319b Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).