GNU bug report logs - #78640
elisp url.el cannot handle some valid URLs

Previous Next

Package: emacs;

Reported by: 林羽 <0713ws <at> gmail.com>

Date: Fri, 30 May 2025 03:59:02 UTC

Severity: normal

Tags: fixed

Fixed in version 31.1

Done: Robert Pluim <rpluim <at> gmail.com>

To reply to this bug, email your comments to 78640 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#78640; Package emacs. (Fri, 30 May 2025 03:59:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to 林羽 <0713ws <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 30 May 2025 03:59:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: 林羽 <0713ws <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: elisp url.el cannot handle some valid URLs
Date: Fri, 30 May 2025 10:57:26 +0800
[Message part 1 (text/plain, inline)]
(url-insert-file-contents “http://127.0.0.1:9999?test=1
<http://127.0.0.1:9999/?test=1>”)

GET ?test=1 HTTP/1.1 MIME-Version: 1.0 Connection: keep-alive Host:
127.0.0.1:9999 Accept-encoding: gzip Accept: */* User-Agent: URL/Emacs
Emacs/31.0.50 (TTY; x86_64-suse-linux-gnu)

Should it be /?test=1, Missing "/" This url complies with the RFC 3986
standard and can be handled normally in tools such as curl
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78640; Package emacs. (Sat, 31 May 2025 15:13:02 GMT) Full text and rfc822 format available.

Message #8 received at 78640 <at> debbugs.gnu.org (full text, mbox):

From: 林羽 <0713ws <at> gmail.com>
To: 78640 <at> debbugs.gnu.org
Date: Sat, 31 May 2025 23:12:26 +0800
[Message part 1 (text/plain, inline)]
More description about this issue
https://emacs-china.org/t/elisp-url-bug/29576  ,I hope that lisp can handle
URLs in the same way as other tools.
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78640; Package emacs. (Sat, 07 Jun 2025 08:54:02 GMT) Full text and rfc822 format available.

Message #11 received at 78640 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: 林羽 <0713ws <at> gmail.com>, Robert Pluim <rpluim <at> gmail.com>
Cc: 78640 <at> debbugs.gnu.org
Subject: Re: bug#78640: elisp url.el cannot handle some valid URLs
Date: Sat, 07 Jun 2025 11:53:17 +0300
> From: 林羽 <0713ws <at> gmail.com>
> Date: Fri, 30 May 2025 10:57:26 +0800
> 
> (url-insert-file-contents “http://127.0.0.1:9999?test=1”) 
> 
> GET ?test=1 HTTP/1.1 MIME-Version: 1.0 Connection: keep-alive Host: 127.0.0.1:9999 Accept-encoding:
> gzip Accept: */* User-Agent: URL/Emacs Emacs/31.0.50 (TTY; x86_64-suse-linux-gnu)
> 
> Should it be /?test=1, Missing "/" This url complies with the RFC 3986 standard and can be handled
> normally in tools such as curl

Robert, any comments?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78640; Package emacs. (Mon, 09 Jun 2025 09:03:02 GMT) Full text and rfc822 format available.

Message #14 received at 78640 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 78640 <at> debbugs.gnu.org, 林羽 <0713ws <at> gmail.com>
Subject: Re: bug#78640: elisp url.el cannot handle some valid URLs
Date: Mon, 09 Jun 2025 11:02:44 +0200
>>>>> On Sat, 07 Jun 2025 11:53:17 +0300, Eli Zaretskii <eliz <at> gnu.org> said:

    >> From: 林羽 <0713ws <at> gmail.com>
    >> Date: Fri, 30 May 2025 10:57:26 +0800
    >> 
    >> (url-insert-file-contents “http://127.0.0.1:9999?test=1”) 
    >> 
    >> GET ?test=1 HTTP/1.1 MIME-Version: 1.0 Connection: keep-alive Host: 127.0.0.1:9999 Accept-encoding:
    >> gzip Accept: */* User-Agent: URL/Emacs Emacs/31.0.50 (TTY; x86_64-suse-linux-gnu)
    >> 
    >> Should it be /?test=1, Missing "/" This url complies with the RFC 3986 standard and can be handled
    >> normally in tools such as curl

    Eli> Robert, any comments?

Yes, an empty path there should be replaced with "/" when we issue the
command. Fixing the http case is easy enough, but similar changes are
probably required for other schemes. Patch below.

Changing the url parsing code to return "/?test=1" would probably work
as well, but that would be a much bigger and riskier change (and we
donʼt have any tests for this stuff).

Robert
-- 
diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el
index 4258da33a33..5a8279a4122 100644
--- a/lisp/url/url-http.el
+++ b/lisp/url/url-http.el
@@ -325,8 +325,12 @@ url-http-create-request
 					  url-http-target-url)
                                          nil 'any nil)))
          (ref-url (url-http--encode-string url-http-referer)))
-    (if (equal "" real-fname)
-	(setq real-fname "/"))
+    (cond ((equal "" real-fname)
+	   (setq real-fname "/"))
+          ;; RFC 3986 section 6.2.3 says an empty path should be
+          ;; normalized to "/".  (Bug#78640)
+          ((not (eq (aref real-fname 0) ?/))
+           (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")))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78640; Package emacs. (Mon, 09 Jun 2025 10:02:02 GMT) Full text and rfc822 format available.

Message #17 received at 78640 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 78640 <at> debbugs.gnu.org,
 林羽 <0713ws <at> gmail.com>
Subject: Re: bug#78640: elisp url.el cannot handle some valid URLs
Date: Mon, 09 Jun 2025 12:01:23 +0200
On Jun 09 2025, Robert Pluim wrote:

> diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el
> index 4258da33a33..5a8279a4122 100644
> --- a/lisp/url/url-http.el
> +++ b/lisp/url/url-http.el
> @@ -325,8 +325,12 @@ url-http-create-request
>  					  url-http-target-url)
>                                           nil 'any nil)))
>           (ref-url (url-http--encode-string url-http-referer)))
> -    (if (equal "" real-fname)
> -	(setq real-fname "/"))
> +    (cond ((equal "" real-fname)
> +	   (setq real-fname "/"))
> +          ;; RFC 3986 section 6.2.3 says an empty path should be
> +          ;; normalized to "/".  (Bug#78640)
> +          ((not (eq (aref real-fname 0) ?/))
> +           (setq real-fname (concat "/" real-fname))))

The two conditions could be combined since (concat "/" real-fname) also
works if real-fname is "".

  (if (not (string-match-p "\\`/" real-fname))
      (setq real-fname (concat "/" real-fname)))

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78640; Package emacs. (Mon, 09 Jun 2025 12:49:02 GMT) Full text and rfc822 format available.

Message #20 received at 78640 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 78640 <at> debbugs.gnu.org,
 林羽 <0713ws <at> gmail.com>
Subject: Re: bug#78640: elisp url.el cannot handle some valid URLs
Date: Mon, 09 Jun 2025 14:47:57 +0200
>>>>> On Mon, 09 Jun 2025 12:01:23 +0200, Andreas Schwab <schwab <at> linux-m68k.org> said:

    Andreas> The two conditions could be combined since (concat "/" real-fname) also
    Andreas> works if real-fname is "".

    Andreas>   (if (not (string-match-p "\\`/" real-fname))
    Andreas>       (setq real-fname (concat "/" real-fname)))

Sure. Although I think Iʼll use `unless' and invert the test.

Robert
-- 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78640; Package emacs. (Mon, 09 Jun 2025 14:43:03 GMT) Full text and rfc822 format available.

Message #23 received at 78640 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: 78640 <at> debbugs.gnu.org, schwab <at> linux-m68k.org, 0713ws <at> gmail.com
Subject: Re: bug#78640: elisp url.el cannot handle some valid URLs
Date: Mon, 09 Jun 2025 17:42:27 +0300
> From: Robert Pluim <rpluim <at> gmail.com>
> Cc: Eli Zaretskii <eliz <at> gnu.org>,  78640 <at> debbugs.gnu.org,  林羽
>  <0713ws <at> gmail.com>
> Date: Mon, 09 Jun 2025 14:47:57 +0200
> 
> >>>>> On Mon, 09 Jun 2025 12:01:23 +0200, Andreas Schwab <schwab <at> linux-m68k.org> said:
> 
>     Andreas> The two conditions could be combined since (concat "/" real-fname) also
>     Andreas> works if real-fname is "".
> 
>     Andreas>   (if (not (string-match-p "\\`/" real-fname))
>     Andreas>       (setq real-fname (concat "/" real-fname)))
> 
> Sure. Although I think Iʼll use `unless' and invert the test.

Thanks, feel free to install on the master branch.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78640; Package emacs. (Wed, 11 Jun 2025 15:28:02 GMT) Full text and rfc822 format available.

Message #26 received at 78640 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 78640 <at> debbugs.gnu.org, schwab <at> linux-m68k.org, 0713ws <at> gmail.com
Subject: Re: bug#78640: elisp url.el cannot handle some valid URLs
Date: Wed, 11 Jun 2025 17:27:14 +0200
tags 78640 fixed
close 78640 31.1
quit

>>>>> On Mon, 09 Jun 2025 17:42:27 +0300, Eli Zaretskii <eliz <at> gnu.org> said:

    >> From: Robert Pluim <rpluim <at> gmail.com>
    >> Cc: Eli Zaretskii <eliz <at> gnu.org>,  78640 <at> debbugs.gnu.org,  林羽
    >> <0713ws <at> gmail.com>
    >> Date: Mon, 09 Jun 2025 14:47:57 +0200
    >> 
    >> >>>>> On Mon, 09 Jun 2025 12:01:23 +0200, Andreas Schwab <schwab <at> linux-m68k.org> said:
    >> 
    Andreas> The two conditions could be combined since (concat "/" real-fname) also
    Andreas> works if real-fname is "".
    >> 
    Andreas> (if (not (string-match-p "\\`/" real-fname))
    Andreas> (setq real-fname (concat "/" real-fname)))
    >> 
    >> Sure. Although I think Iʼll use `unless' and invert the test.

    Eli> Thanks, feel free to install on the master branch.

Done

Robert
-- 

Pushed to master.

7e62c2cf3aa 2025-06-11T17:10:46+02:00 "Normalize URL path correctly for http"
https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=7e62c2cf3aadb52397bcff8439d00084cd36afa0





Added tag(s) fixed. Request was from Robert Pluim <rpluim <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 11 Jun 2025 15:28:02 GMT) Full text and rfc822 format available.

bug marked as fixed in version 31.1, send any further explanations to 78640 <at> debbugs.gnu.org and 林羽 <0713ws <at> gmail.com> Request was from Robert Pluim <rpluim <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 11 Jun 2025 15:28:03 GMT) Full text and rfc822 format available.

This bug report was last modified 6 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.