From 052a9934380fdd7517b5bf38aca37aaf951a644e Mon Sep 17 00:00:00 2001 From: Daniele Nicolodi Date: Fri, 10 Jul 2020 12:16:01 -0600 Subject: [PATCH 1/2] url-http: Fix handling of redirect locations Do not break the redirect Location header when it contain spaces. In RFC 7231 the Location header is defined to carry a URI-reference. According to RFC 3986 it should be percent-encoded and thus should not contain spaces. However, there are HTTP server implementation (notably nginx) that do not do that. This makes Emacs url-http.el behave like most other HTTP client implementatios. Also remove the stripping of angle bracket quotes as they are not valid according to the RFCs. --- lisp/url/url-http.el | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el index 669c24571f..a746be8475 100644 --- a/lisp/url/url-http.el +++ b/lisp/url/url-http.el @@ -702,12 +702,6 @@ should be shown to the user." ;; Treat everything like '300' nil)) (when redirect-uri - ;; Clean off any whitespace and/or <...> cruft. - (if (string-match "\\([^ \t]+\\)[ \t]" redirect-uri) - (setq redirect-uri (match-string 1 redirect-uri))) - (if (string-match "^<\\(.*\\)>$" redirect-uri) - (setq redirect-uri (match-string 1 redirect-uri))) - ;; Some stupid sites (like sourceforge) send a ;; non-fully-qualified URL (ie: /), which royally confuses ;; the URL library. -- 2.24.3 (Apple Git-128)