ucb/source/ucp/webdav-curl/CurlSession.cxx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
New commits: commit 0c8e6165fcdf060d7830f8d597686f39d19c2ffa Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Thu Jan 13 20:00:03 2022 +0100 Commit: Thorsten Behrens <thorsten.behr...@allotropia.de> CommitDate: Fri Jan 14 12:28:54 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> (cherry picked from commit 2a506a2e2b747e28e1684e0748fa3d237c65772b) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128344 Reviewed-by: Thorsten Behrens <thorsten.behr...@allotropia.de> diff --git a/ucb/source/ucp/webdav-curl/CurlSession.cxx b/ucb/source/ucp/webdav-curl/CurlSession.cxx index 59f372fa809b..c30b0c775131 100644 --- a/ucb/source/ucp/webdav-curl/CurlSession.cxx +++ b/ucb/source/ucp/webdav-curl/CurlSession.cxx @@ -268,7 +268,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*/) { @@ -284,10 +283,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; @@ -311,7 +317,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) @@ -622,7 +627,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);