Kaydet (Commit) 03f58aa3 authored tarafından Mike Kaganski's avatar Mike Kaganski

dbaccess: properly encode path to prevent stripping "fragment" from it

When a path contains "#" character, it must be encoded to prevent
detecting it as URI's "fragment" separator, and subsequent stripping of
following path part (e.g., in SfxMedium::Init_Impl).

Change-Id: Ide08f8c13dc2296d9aecba92c96f1b29cc4538de
Reviewed-on: https://gerrit.libreoffice.org/44538Reviewed-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
Tested-by: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 38c03b07
......@@ -368,7 +368,11 @@ Reference< XInterface > ODatabaseContext::loadObjectFromURL(const OUString& _rNa
if (bEmbeddedDataSource)
{
// In this case the host contains the real path, and the path is the embedded stream name.
OUString sBaseURI = aURL.GetHost(INetURLObject::DecodeMechanism::WithCharset) + aURL.GetURLPath(INetURLObject::DecodeMechanism::WithCharset);
OUString sBaseURI =
INetURLObject::encode(aURL.GetHost(INetURLObject::DecodeMechanism::WithCharset),
INetURLObject::PART_FPATH, INetURLObject::EncodeMechanism::All)
+ INetURLObject::encode(aURL.GetURLPath(INetURLObject::DecodeMechanism::WithCharset),
INetURLObject::PART_FPATH, INetURLObject::EncodeMechanism::All);
aArgs.put("BaseURI", sBaseURI);
}
......
......@@ -311,8 +311,10 @@ bool ODBFilter::implImport( const Sequence< PropertyValue >& rDescriptor )
{
// In this case the host contains the real path, and the path is the embedded stream name.
INetURLObject aURL(sFileName);
sFileName = aURL.GetHost(INetURLObject::DecodeMechanism::WithCharset);
sStreamRelPath = aURL.GetURLPath(INetURLObject::DecodeMechanism::WithCharset);
sFileName = INetURLObject::encode(aURL.GetHost(INetURLObject::DecodeMechanism::WithCharset),
INetURLObject::PART_FPATH, INetURLObject::EncodeMechanism::All);
sStreamRelPath = INetURLObject::encode(aURL.GetURLPath(INetURLObject::DecodeMechanism::WithCharset),
INetURLObject::PART_FPATH, INetURLObject::EncodeMechanism::All);
if (sStreamRelPath.startsWith("/"))
sStreamRelPath = sStreamRelPath.copy(1);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment