diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-11-09 23:13:16 +0100 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2017-11-10 14:31:45 +0100 |
commit | bff8d843bd4e5dcca5dc1a60c2c7852b1b72a00b (patch) | |
tree | 5e7c051c7b01892ce09380d63d0dddc3c63095be /sw | |
parent | 34a7a9fd7649655256a85b5701d461af5ccc2016 (diff) |
Properly construct vnd.sun.star.pkg URL
...in SwDBManager::LoadAndRegisterEmbeddedDataSource. For example, when the
authority encodes a file URL whose path contains '%23' (because one of the
pathname segments encoded in the file URL contains a '#' character), the
original code would have left it as %23 in the vnd.sun.star.pkg URL, instead of
encoding it as %2523. That lead to bad file URLs being recovered from the
vnd.sun.star.pkg URL in dbaccess. (And 03f58aa36c5150ea305b5fd0023e0ec53a334051
"dbaccess: properly encode path to prevent stripping 'fragment' from it", which
this commit reverts, wrongly tried to address that on the consuming instead of
the producing side.)
Change-Id: I17d2dc9e6306d006361fbcb63d77e93a9e20bf31
Reviewed-on: https://gerrit.libreoffice.org/44569
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/uibase/dbui/dbmgr.cxx | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/sw/source/uibase/dbui/dbmgr.cxx b/sw/source/uibase/dbui/dbmgr.cxx index 5cf02afffd2d..47cd5f13d469 100644 --- a/sw/source/uibase/dbui/dbmgr.cxx +++ b/sw/source/uibase/dbui/dbmgr.cxx @@ -17,6 +17,9 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <cassert> #include <cstdarg> #include <unotxdoc.hxx> @@ -26,6 +29,8 @@ #include <com/sun/star/sdb/XDocumentDataSource.hpp> #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/lang/XEventListener.hpp> +#include <com/sun/star/uri/UriReferenceFactory.hpp> +#include <com/sun/star/uri/VndSunStarPkgUrlReferenceFactory.hpp> #include <com/sun/star/util/NumberFormatter.hpp> #include <com/sun/star/sdb/DatabaseContext.hpp> #include <com/sun/star/sdb/TextConnectionSettings.hpp> @@ -2858,9 +2863,17 @@ void SwDBManager::LoadAndRegisterEmbeddedDataSource(const SwDBData& rData, const // Encode the stream name and the real path into a single URL. const INetURLObject& rURLObject = rDocShell.GetMedium()->GetURLObject(); - OUString aURL = "vnd.sun.star.pkg://"; - aURL += INetURLObject::encode(rURLObject.GetMainURL(INetURLObject::DecodeMechanism::WithCharset), INetURLObject::PART_AUTHORITY, INetURLObject::EncodeMechanism::All); - aURL += "/" + INetURLObject::encode(m_sEmbeddedName, INetURLObject::PART_FPATH, INetURLObject::EncodeMechanism::All); + auto xContext(comphelper::getProcessComponentContext()); + auto xUri = css::uri::UriReferenceFactory::create(xContext) + ->parse(rURLObject.GetMainURL(INetURLObject::DecodeMechanism::NONE)); + assert(xUri.is()); + xUri = css::uri::VndSunStarPkgUrlReferenceFactory::create(xContext) + ->createVndSunStarPkgUrlReference(xUri); + assert(xUri.is()); + OUString const aURL = xUri->getUriReference() + "/" + + INetURLObject::encode( + m_sEmbeddedName, INetURLObject::PART_FPATH, + INetURLObject::EncodeMechanism::All); uno::Reference<uno::XInterface> xDataSource(xDatabaseContext->getByName(aURL), uno::UNO_QUERY); xDatabaseContext->registerObject( sDataSource, xDataSource ); |