diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-05-07 11:49:48 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-05-07 13:34:31 +0200 |
commit | 54d07afac60d68fae9910724c5f273658e9a82cc (patch) | |
tree | 73c3b06722c96ed883991fd8b0ac64086baacf74 /fpicker/source | |
parent | dfb0d118f6b23730bc632885eb4703a37eeaec16 (diff) |
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.kaganski@collabora.com>
Diffstat (limited to 'fpicker/source')
-rw-r--r-- | fpicker/source/win32/VistaFilePickerImpl.cxx | 9 |
1 files changed, 6 insertions, 3 deletions
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)) { |