GNU bug report logs -
#78640
elisp url.el cannot handle some valid URLs
Previous Next
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>
Full log
View this message in rfc822 format
>>>>> 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")))
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.