diff options
author | Michael Stahl <michael.stahl@allotropia.de> | 2021-11-26 16:29:08 +0100 |
---|---|---|
committer | Thorsten Behrens <thorsten.behrens@allotropia.de> | 2021-11-27 00:18:13 +0100 |
commit | db8edd163cf453bbb9b85c2a17c78da49df27cdf (patch) | |
tree | 080340d1edd9bd4f608f73e839c7e438fa679040 /ucb/source | |
parent | 1061b3443ffbc5db0051074b428e59ba39fe24ca (diff) |
ucb: webdav-curl: fix CurlUri::CloneWithRelativeRefPathAbsolute()
Change-Id: Idf1d75817009286cd79a00c0ba154cea70e2ffda
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125908
Tested-by: Jenkins
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
(cherry picked from commit b03e070420606d407df2ec5e9dfa7043ecc46177)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125895
Reviewed-by: Thorsten Behrens <thorsten.behrens@allotropia.de>
Diffstat (limited to 'ucb/source')
-rw-r--r-- | ucb/source/ucp/webdav-curl/CurlUri.cxx | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/ucb/source/ucp/webdav-curl/CurlUri.cxx b/ucb/source/ucp/webdav-curl/CurlUri.cxx index 533a77606f47..035c12a132ef 100644 --- a/ucb/source/ucp/webdav-curl/CurlUri.cxx +++ b/ucb/source/ucp/webdav-curl/CurlUri.cxx @@ -243,33 +243,42 @@ CurlUri CurlUri::CloneWithRelativeRefPathAbsolute(OUString const& rRelativeRef) sal_Int32 indexEnd(rRelativeRef.getLength()); auto const indexQuery(rRelativeRef.indexOf('?')); auto const indexFragment(rRelativeRef.indexOf('#')); + CURLUcode uc; if (indexFragment != -1) { - OUString const fragment(rRelativeRef.copy(indexFragment)); + OUString const fragment(rRelativeRef.copy(indexFragment + 1)); indexEnd = indexFragment; OString const utf8Fragment(OUStringToOString(fragment, RTL_TEXTENCODING_UTF8)); - auto const uc = curl_url_set(pUrl.get(), CURLUPART_QUERY, utf8Fragment.getStr(), 0); - if (uc != CURLUE_OK) - { - SAL_WARN("ucb.ucp.webdav.curl", "curl_url_set failed: " << uc); - throw DAVException(DAVException::DAV_INVALID_ARG); - } + uc = curl_url_set(pUrl.get(), CURLUPART_FRAGMENT, utf8Fragment.getStr(), 0); + } + else + { + uc = curl_url_set(pUrl.get(), CURLUPART_FRAGMENT, nullptr, 0); + } + if (uc != CURLUE_OK) + { + SAL_WARN("ucb.ucp.webdav.curl", "curl_url_set failed: " << uc); + throw DAVException(DAVException::DAV_INVALID_ARG); } if (indexQuery != -1 && (indexFragment == -1 || indexQuery < indexFragment)) { - OUString const query(rRelativeRef.copy(indexQuery, indexEnd - indexQuery)); + OUString const query(rRelativeRef.copy(indexQuery + 1, indexEnd - indexQuery - 1)); indexEnd = indexQuery; OString const utf8Query(OUStringToOString(query, RTL_TEXTENCODING_UTF8)); - auto const uc = curl_url_set(pUrl.get(), CURLUPART_QUERY, utf8Query.getStr(), 0); - if (uc != CURLUE_OK) - { - SAL_WARN("ucb.ucp.webdav.curl", "curl_url_set failed: " << uc); - throw DAVException(DAVException::DAV_INVALID_ARG); - } + uc = curl_url_set(pUrl.get(), CURLUPART_QUERY, utf8Query.getStr(), 0); + } + else + { + uc = curl_url_set(pUrl.get(), CURLUPART_QUERY, nullptr, 0); + } + if (uc != CURLUE_OK) + { + SAL_WARN("ucb.ucp.webdav.curl", "curl_url_set failed: " << uc); + throw DAVException(DAVException::DAV_INVALID_ARG); } OUString const path(rRelativeRef.copy(0, indexEnd)); OString const utf8Path(OUStringToOString(path, RTL_TEXTENCODING_UTF8)); - auto const uc = curl_url_set(pUrl.get(), CURLUPART_PATH, utf8Path.getStr(), 0); + uc = curl_url_set(pUrl.get(), CURLUPART_PATH, utf8Path.getStr(), 0); if (uc != CURLUE_OK) { SAL_WARN("ucb.ucp.webdav.curl", "curl_url_set failed: " << uc); |