bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#42382: 26.3; url-http handling of Location redirection headers conta


From: Daniele Nicolodi
Subject: bug#42382: 26.3; url-http handling of Location redirection headers containing whitespace
Date: Wed, 15 Jul 2020 14:40:36 -0600
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:68.0) Gecko/20100101 Thunderbird/68.10.0

url-http.el interprets HTTP responses in url-http-parse-headers. This
function contains the following code:

         (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)))

which truncates the value of the Location header at the first whitespace
character and removes surrounding angle brackets quoting.

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. While this is a bug in those HTTP server
implementations, I think Emacs should follow what most other HTTP client
implementatios (all the ones I tested) and use the content of the
Location header unmodified. Stripping of angle bracket quotes is
unnecessary as they are not valid according to the RFCs.

Also, accordingly to the RFCs, the location header may contain a
relative location. Thus the comment that suggest that such a response is
a bug in the server should be reworded.

The attached patches implement the proposed changes.

Thank you.

Attachment: 0001-url-http-Fix-handling-of-redirect-locations.patch
Description: Text document

Attachment: 0002-url-http-Do-not-suggest-a-broken-HTTP-server-impleme.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]