From 629068a89d1b2a7babbed7d3f5778834a970de16 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 14 Aug 2019 17:53:14 +0300 Subject: [PATCH] Fix fetching URLs with stuff that looks like HTTP headers * lisp/url/url-http.el (url-http-parse-headers): Narrow the buffer to the headers at the beginning to make sure url-handle-content-transfer-encoding uses the correct headers. (Bug#37023) --- lisp/url/url-http.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el index 9b690778fc0..94d1ba9668b 100644 --- a/lisp/url/url-http.el +++ b/lisp/url/url-http.el @@ -949,6 +949,10 @@ should be shown to the user." class url-http-response-status))) (if (not success) (url-mark-buffer-as-dead buffer) + ;; Narrow the buffer for url-handle-content-transfer-encoding to + ;; find only the headers relevant to this transaction. + (and (not (buffer-narrowed-p) + (mail-narrow-to-head))) (url-handle-content-transfer-encoding)) (url-http-debug "Finished parsing HTTP headers: %S" success) (widen) -- 2.39.2