fpicker/source/win32/VistaFilePickerImpl.cxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
New commits: commit 54d07afac60d68fae9910724c5f273658e9a82cc Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Sun May 7 11:49:48 2023 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Sun May 7 13:34:31 2023 +0200 tdf#155176: only use item's URL in case filesystem path failed I was daydreaming, when thought that we can rely on the system-provided file URL. Windows creates such URLs using current 8-bit codepage, and URL-encodes the octets from that string, which fails when the URL is treated as UTF-8 after URL-decode. Change-Id: I2703586d371c1254e693a5760c5b6b74101e299d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151456 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/fpicker/source/win32/VistaFilePickerImpl.cxx b/fpicker/source/win32/VistaFilePickerImpl.cxx index fa58efc6c5d9..67e977156bd2 100644 --- a/fpicker/source/win32/VistaFilePickerImpl.cxx +++ b/fpicker/source/win32/VistaFilePickerImpl.cxx @@ -170,12 +170,15 @@ using TFolderPickerDialogImpl = TDialogImpl<TFileOpenDialog, CLSID_FileOpenDialo static OUString lcl_getURLFromShellItem (IShellItem* pItem) { sal::systools::CoTaskMemAllocated<wchar_t> pStr; - if (SUCCEEDED(pItem->GetDisplayName(SIGDN_URL, &pStr))) - return OUString(o3tl::toU(pStr)); - HRESULT hr = pItem->GetDisplayName(SIGDN_FILESYSPATH, &pStr); if (FAILED(hr)) { + // tdf#155176: One could think that querying SIGDN_URL would go first. But Windows uses + // current 8-bit codepage for the filenames, and URL-encodes those octets. So check it + // only after SIGDN_FILESYSPATH query failed (can it ever happen?) + if (SUCCEEDED(pItem->GetDisplayName(SIGDN_URL, &pStr))) + return OUString(o3tl::toU(pStr)); + hr = pItem->GetDisplayName(SIGDN_PARENTRELATIVEPARSING, &pStr); if (SUCCEEDED(hr)) {