summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2022-07-14 17:57:18 +0200
committerMichael Stahl <michael.stahl@allotropia.de>2022-07-18 16:42:34 +0200
commit54aebc2c8ff25f17a4083fe6c60c38c4f391af12 (patch)
tree0f8e4aa7e5029768ff3be9f31faaa8e3f9e50d45 /tools
parentd996563ef15892aace8c6b31fe3d2097cbbd6093 (diff)
tools: try to work around DavGetHTTPFromUNCPath() not URL-encoding path
This was added in commit 20b1e6440aacab043753e93be4499e939a80b05b "tdf#126121: WebDAV redirection detection" and it works fine when i test it on my local Windows 10, returning an URL with encoded path. The logs from the customer system however show a http URL containing an unencoded ' ' in the path, which curl_url_set chokes on. Try to encode the returned URL with rtl_UriEncodeKeepEscapes, which should hopefully work in either situation. Change-Id: I6862fe0828307a13b0004b192153747d85bb3a42 (cherry picked from commit 66e25aad35cf538da86bdd0157428f4bed95258d) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137173 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'tools')
-rw-r--r--tools/source/fsys/fileutil.cxx7
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/source/fsys/fileutil.cxx b/tools/source/fsys/fileutil.cxx
index ec20e0a513bf..0e3512e5a160 100644
--- a/tools/source/fsys/fileutil.cxx
+++ b/tools/source/fsys/fileutil.cxx
@@ -10,6 +10,7 @@
#include <tools/fileutil.hxx>
#if defined _WIN32
#include <osl/file.hxx>
+#include <rtl/uri.hxx>
#include <o3tl/char16_t2wchar_t.hxx>
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
@@ -29,7 +30,11 @@ OUString UNCToDavURL(LPCWSTR sUNC)
bufURL = std::make_unique<wchar_t[]>(nSize);
nResult = DavGetHTTPFromUNCPath(sUNC, bufURL.get(), &nSize);
}
- return nResult == ERROR_SUCCESS ? OUString(o3tl::toU(bufURL.get())) : OUString();
+ // looks like on different Windowses this may or may not be URL encoded?
+ return nResult == ERROR_SUCCESS
+ ? ::rtl::Uri::encode(OUString(o3tl::toU(bufURL.get())), rtl_UriCharClassUric,
+ rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_UTF8)
+ : OUString();
}
#endif
}