ucb/source/ucp/webdav-curl/CurlSession.cxx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
New commits: commit 2a506a2e2b747e28e1684e0748fa3d237c65772b Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Thu Jan 13 20:00:03 2022 +0100 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Fri Jan 14 11:12:18 2022 +0100 ucb: webdav-curl: build debug callback also in release builds And fix the Authorization header redaction, it was assuming there is one call per header line, but all headers are passed in one call. Change-Id: Idf86b9e0a4a8f8e9fb39098402a002abc394a589 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128395 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx b/ucb/source/ucp/webdav-curl/CurlSession.cxx index 09fddeb95203..89c60cbac1cc 100644 --- a/ucb/source/ucp/webdav-curl/CurlSession.cxx +++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx @@ -266,7 +266,6 @@ namespace http_dav_ucp { // libcurl callbacks: -#if OSL_DEBUG_LEVEL > 0 static int debug_callback(CURL* handle, curl_infotype type, char* data, size_t size, void* /*userdata*/) { @@ -282,10 +281,17 @@ static int debug_callback(CURL* handle, curl_infotype type, char* data, size_t s return 0; case CURLINFO_HEADER_OUT: { + // unlike IN, this is all headers in one call OString tmp(data, size); - if (tmp.startsWith("Authorization: ")) + sal_Int32 const start(tmp.indexOf("Authorization: ")); + if (start != -1) { - tmp = "Authorization: " + OString::number(tmp.getLength() - 15) + " bytes redacted"; + sal_Int32 const end(tmp.indexOf("\r\n", start)); + assert(end != -1); + sal_Int32 const len(SAL_N_ELEMENTS("Authorization: ") - 1); + tmp = tmp.replaceAt( + start + len, end - start - len, + OStringConcatenation(OString::number(end - start - len) + " bytes redacted")); } SAL_INFO("ucb.ucp.webdav.curl", "CURLINFO_HEADER_OUT: " << handle << ": " << tmp); return 0; @@ -309,7 +315,6 @@ static int debug_callback(CURL* handle, curl_infotype type, char* data, size_t s SAL_INFO("ucb.ucp.webdav.curl", "debug log: " << handle << ": " << pType << " " << size); return 0; } -#endif static size_t write_callback(char* const ptr, size_t const size, size_t const nmemb, void* const userdata) @@ -620,7 +625,7 @@ CurlSession::CurlSession(uno::Reference<uno::XComponentContext> const& xContext, // this supposedly gives the highest quality error reporting rc = curl_easy_setopt(m_pCurl.get(), CURLOPT_ERRORBUFFER, m_ErrorBuffer); assert(rc == CURLE_OK); -#if OSL_DEBUG_LEVEL > 0 +#if 1 // just for debugging... rc = curl_easy_setopt(m_pCurl.get(), CURLOPT_DEBUGFUNCTION, debug_callback); assert(rc == CURLE_OK);