tools: try to work around DavGetHTTPFromUNCPath() not URL-encoding path
This was added in commit 20b1e6440a
"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>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user