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>
This commit is contained in:
parent
dfb0d118f6
commit
54d07afac6
@ -170,12 +170,15 @@ using TFolderPickerDialogImpl = TDialogImpl<TFileOpenDialog, CLSID_FileOpenDialo
|
|||||||
static OUString lcl_getURLFromShellItem (IShellItem* pItem)
|
static OUString lcl_getURLFromShellItem (IShellItem* pItem)
|
||||||
{
|
{
|
||||||
sal::systools::CoTaskMemAllocated<wchar_t> pStr;
|
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);
|
HRESULT hr = pItem->GetDisplayName(SIGDN_FILESYSPATH, &pStr);
|
||||||
if (FAILED(hr))
|
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);
|
hr = pItem->GetDisplayName(SIGDN_PARENTRELATIVEPARSING, &pStr);
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user