tdf#164686: handle exceptions from UCBContentHelper::Exists

When a filename can be treated as a non-file URL, checking its existence
may throw. This needs to be handled here.

Handles '?' in the filename.

Change-Id: If065c483d1a44cbbfcea21f91d72adf1fdfde579
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180199
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Mike Kaganski
2025-01-13 21:30:28 +05:00
parent a9bf19d0d3
commit 12664b7cea

View File

@@ -833,7 +833,18 @@ void SvtFileDialog::OpenHdl_Impl(void const * pVoid)
{
case FILEDLG_MODE_SAVE:
{
if ( ::utl::UCBContentHelper::Exists( aFileObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) ) )
bool exists;
try
{
exists = utl::UCBContentHelper::Exists( aFileObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
}
catch (const Exception&)
{
DBG_UNHANDLED_EXCEPTION("fpicker.office");
ErrorHandler::HandleError(ERRCODE_IO_GENERAL);
return;
}
if (exists)
{
OUString aMsg = FpsResId(STR_SVT_ALREADYEXISTOVERWRITE);
aMsg = aMsg.replaceFirst(