summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2023-02-13 11:22:03 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2023-02-13 11:29:34 +0000
commit00f6c36b603416b73e1327ac4c862b1eaca2d277 (patch)
treee9004fd7ae4ea91a9d8908fe86ea0e0d97801bef /sfx2
parentb926ba60d11cb78b4e042e2abb2d00dde128a1f8 (diff)
Fix/simplify some vnd.sun.star.expand: handling
The vnd.sun.star.expand: payload must be URL-decoded prior to passing it to expandMacros; the protocol must be checked case-insensitively. Use startsWithIgnoreAsciiCase for that. Change-Id: I2be993a0400a27cb7dc57207cd0824b4505afd2b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146855 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/doc/DocumentMetadataAccess.cxx3
-rw-r--r--sfx2/source/doc/doctemplates.cxx12
2 files changed, 5 insertions, 10 deletions
diff --git a/sfx2/source/doc/DocumentMetadataAccess.cxx b/sfx2/source/doc/DocumentMetadataAccess.cxx
index 309728d816e3..42ec35c9f304 100644
--- a/sfx2/source/doc/DocumentMetadataAccess.cxx
+++ b/sfx2/source/doc/DocumentMetadataAccess.cxx
@@ -156,10 +156,9 @@ uno::Reference<rdf::XURI> createBaseURI(
// #i108078# workaround non-hierarchical vnd.sun.star.expand URIs
// this really should be done somewhere else, not here.
- if (pkgURI.matchIgnoreAsciiCase("vnd.sun.star.expand:"))
+ if (pkgURI.startsWithIgnoreAsciiCase("vnd.sun.star.expand:", &pkgURI))
{
// expand it here (makeAbsolute requires hierarchical URI)
- pkgURI = pkgURI.copy( RTL_CONSTASCII_LENGTH("vnd.sun.star.expand:") );
if (!pkgURI.isEmpty()) {
pkgURI = ::rtl::Uri::decode(
pkgURI, rtl_UriDecodeStrict, RTL_TEXTENCODING_UTF8);
diff --git a/sfx2/source/doc/doctemplates.cxx b/sfx2/source/doc/doctemplates.cxx
index d16b5dabf21d..80b7b600871c 100644
--- a/sfx2/source/doc/doctemplates.cxx
+++ b/sfx2/source/doc/doctemplates.cxx
@@ -20,6 +20,7 @@
#include <osl/mutex.hxx>
#include <comphelper/diagnose_ex.hxx>
#include <tools/urlobj.hxx>
+#include <rtl/uri.hxx>
#include <rtl/ustring.hxx>
#include <sal/log.hxx>
#include <utility>
@@ -542,8 +543,6 @@ void SfxDocTplService_Impl::getDirList()
maTemplateDirs = Sequence< OUString >( nCount );
uno::Reference< util::XMacroExpander > xExpander = util::theMacroExpander::get(mxContext);
- static const OUStringLiteral aPrefix(
- u"vnd.sun.star.expand:" );
sal_Int32 nIdx{ 0 };
for (auto& rTemplateDir : asNonConstRange(maTemplateDirs))
@@ -552,13 +551,10 @@ void SfxDocTplService_Impl::getDirList()
aURL.SetURL( o3tl::getToken(aDirs, 0, C_DELIM, nIdx ) );
rTemplateDir = aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- if ( xExpander.is() )
+ if (xExpander && rTemplateDir.startsWithIgnoreAsciiCase("vnd.sun.star.expand:", &rTemplateDir))
{
- const sal_Int32 nIndex{ rTemplateDir.indexOf( aPrefix ) };
- if (nIndex<0)
- continue;
-
- rTemplateDir = rTemplateDir.replaceAt(nIndex, aPrefix.getLength(), u"");
+ rTemplateDir
+ = rtl::Uri::decode(rTemplateDir, rtl_UriDecodeStrict, RTL_TEXTENCODING_UTF8);
rTemplateDir = xExpander->expandMacros( rTemplateDir );
}
}