diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2022-01-13 20:00:03 +0100 |
---|---|---|
committer | Michael Stahl <michael.stahl@allotropia.de> | 2022-01-14 11:12:18 +0100 |
commit | 2a506a2e2b747e28e1684e0748fa3d237c65772b (patch) | |
tree | bdcb3badab6e2a0fba3335737d1429ecf619c2a9 /ucb | |
parent | c8b5debd3f5536839e480ccadb1a1a0ba3a5ceda (diff) |
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.stahl@allotropia.de>
Diffstat (limited to 'ucb')
-rw-r--r-- | ucb/source/ucp/webdav-curl/CurlSession.cxx | 15 |
1 files changed, 10 insertions, 5 deletions
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); |