diff --git a/CHANGES b/CHANGES index 7a819f4edbd6a392e41155608895472969a4d9fe..952e71e442b68e5bf4065f1354b32a6ad96e9fe8 100644 --- a/CHANGES +++ b/CHANGES @@ -277,6 +277,10 @@ o Protocols.HTTP Fixed a memory leak in the HTTP header parser upon receiving malformed HTTP headers. + Fixed a bug where base64 encoded HTTP basic auth tokens were encoded in a + pretty-printed format including line breaks, which lead to malformed HTTP + requests on long username and password combinations. + o Protocols.WebSocket Fixed a case where the onopen callback would get the wrong argument. diff --git a/lib/modules/Protocols.pmod/HTTP.pmod/Session.pike b/lib/modules/Protocols.pmod/HTTP.pmod/Session.pike index d81d1fb9bbd5f17ca72dcb749b3c9d691aa1c060..aed068b92ad3d14d06b45f09ff8e9a3f949c195b 100644 --- a/lib/modules/Protocols.pmod/HTTP.pmod/Session.pike +++ b/lib/modules/Protocols.pmod/HTTP.pmod/Session.pike @@ -95,7 +95,7 @@ class Request if(url->user || url->password) request_headers->authorization = "Basic " + MIME.encode_base64((url->user || "") + ":" + - (url->password || "")); + (url->password || ""), 1); request_headers->connection= (time_to_keep_unused_connections<=0)?"Close":"Keep-Alive"; diff --git a/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod b/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod index 8348563f620395c762f5cf30903b58ef405fc076..920dee12d3c38fa6c66f4869ff95e8f134f484bd 100644 --- a/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod +++ b/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod @@ -181,7 +181,7 @@ constant response_codes = proxy_headers = request_headers + ([]); proxy_headers["Proxy-Authorization"] = "Basic " - + MIME.encode_base64((user || "") + ":" + (password || "")); + + MIME.encode_base64((user || "") + ":" + (password || ""), 1); } if (url->scheme == "http") { @@ -290,7 +290,8 @@ constant response_codes = if(url->user || url->password) default_headers->authorization = "Basic " + MIME.encode_base64(url->user + ":" + - (url->password || "")); + (url->password || ""), + 1); if(!request_headers) request_headers = default_headers; @@ -427,7 +428,8 @@ void do_async_method(string method, if(url->user || url->password) default_headers->authorization = "Basic " + MIME.encode_base64(url->user + ":" + - (url->password || "")); + (url->password || ""), + 1); request_headers = default_headers | request_headers; string query=url->query; @@ -551,7 +553,7 @@ void do_async_proxied_method(string|Standards.URI proxy, proxy_headers = request_headers + ([]); proxy_headers["Proxy-Authorization"] = "Basic " - + MIME.encode_base64((user || "") + ":" + (password || "")); + + MIME.encode_base64((user || "") + ":" + (password || ""), 1); } if (url->scheme == "http") {