From 55c6402be4297d644de774b1fef70b88f91a73e9 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 27 May 2016 18:10:39 +0200 Subject: prevent C++ locale number formatting in text APIs Setting the C++ locale via std::locale::global(std::locale("")); which would otherwise default to the default C locale (aka: unaffected by setlocale) effects the formatting of numeric types in IO streams, which for output for humans is perfectly sensible, but breaks our many text interfaces used and parsed by us and others without expecting the numbers to be formatted. Closes: #825396 (cherry picked from commit b58e2c7c56b1416a343e81f9f80cb1f02c128e25) --- methods/http.cc | 4 ++-- methods/server.cc | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'methods') diff --git a/methods/http.cc b/methods/http.cc index 78b20e66d..0c3803fbb 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -708,7 +708,7 @@ void HttpMethod::SendReq(FetchItem *Itm) C.f. https://tools.ietf.org/wg/httpbis/trac/ticket/158 */ Req << "GET " << requesturi << " HTTP/1.1\r\n"; if (Uri.Port != 0) - Req << "Host: " << ProperHost << ":" << Uri.Port << "\r\n"; + Req << "Host: " << ProperHost << ":" << std::to_string(Uri.Port) << "\r\n"; else Req << "Host: " << ProperHost << "\r\n"; @@ -717,7 +717,7 @@ void HttpMethod::SendReq(FetchItem *Itm) Req << "Cache-Control: no-cache\r\n" << "Pragma: no-cache\r\n"; else if (Itm->IndexFile == true) - Req << "Cache-Control: max-age=" << _config->FindI("Acquire::http::Max-Age",0) << "\r\n"; + Req << "Cache-Control: max-age=" << std::to_string(_config->FindI("Acquire::http::Max-Age",0)) << "\r\n"; else if (_config->FindB("Acquire::http::No-Store",false) == true) Req << "Cache-Control: no-store\r\n"; diff --git a/methods/server.cc b/methods/server.cc index 322b8d94c..a46b40936 100644 --- a/methods/server.cc +++ b/methods/server.cc @@ -130,7 +130,7 @@ bool ServerState::HeaderLine(string Line) { Code[0] = '\0'; if (Owner != NULL && Owner->Debug == true) - clog << "HTTP server doesn't give Reason-Phrase for " << Result << std::endl; + clog << "HTTP server doesn't give Reason-Phrase for " << std::to_string(Result) << std::endl; } else if (elements != 4) return _error->Error(_("The HTTP server sent an invalid reply header")); -- cgit v1.2.3