diff options
-rw-r--r-- | desktop/source/deployment/misc/dp_misc.cxx | 8 | ||||
-rw-r--r-- | filter/source/xsltfilter/XSLTFilter.cxx | 13 | ||||
-rw-r--r-- | scripting/source/basprov/basprov.cxx | 5 | ||||
-rw-r--r-- | sfx2/source/doc/DocumentMetadataAccess.cxx | 3 | ||||
-rw-r--r-- | sfx2/source/doc/doctemplates.cxx | 12 | ||||
-rw-r--r-- | ucb/source/ucp/expand/ucpexpand.cxx | 11 | ||||
-rw-r--r-- | wizards/com/sun/star/wizards/common/FileAccess.java | 10 |
7 files changed, 26 insertions, 36 deletions
diff --git a/desktop/source/deployment/misc/dp_misc.cxx b/desktop/source/deployment/misc/dp_misc.cxx index ea5c737c2d7b..ed394382bb5c 100644 --- a/desktop/source/deployment/misc/dp_misc.cxx +++ b/desktop/source/deployment/misc/dp_misc.cxx @@ -300,9 +300,7 @@ OUString expandUnoRcTerm( OUString const & term_ ) OUString makeRcTerm( OUString const & url ) { OSL_ASSERT( url.match( "vnd.sun.star.expand:" )); - if (url.match( "vnd.sun.star.expand:" )) { - // cut protocol: - OUString rcterm( url.copy( sizeof ("vnd.sun.star.expand:") - 1 ) ); + if (OUString rcterm; url.startsWithIgnoreAsciiCase("vnd.sun.star.expand:", &rcterm)) { // decode uric class chars: rcterm = ::rtl::Uri::decode( rcterm, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); @@ -315,9 +313,7 @@ OUString makeRcTerm( OUString const & url ) OUString expandUnoRcUrl( OUString const & url ) { - if (url.match( "vnd.sun.star.expand:" )) { - // cut protocol: - OUString rcurl( url.copy( sizeof ("vnd.sun.star.expand:") - 1 ) ); + if (OUString rcurl; url.startsWithIgnoreAsciiCase("vnd.sun.star.expand:", &rcurl)) { // decode uric class chars: rcurl = ::rtl::Uri::decode( rcurl, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); diff --git a/filter/source/xsltfilter/XSLTFilter.cxx b/filter/source/xsltfilter/XSLTFilter.cxx index 8ebbd874ed1e..f08933276055 100644 --- a/filter/source/xsltfilter/XSLTFilter.cxx +++ b/filter/source/xsltfilter/XSLTFilter.cxx @@ -31,6 +31,7 @@ #include <comphelper/diagnose_ex.hxx> #include <sal/log.hxx> #include <rtl/ref.hxx> +#include <rtl/uri.hxx> #include <comphelper/interaction.hxx> @@ -207,20 +208,20 @@ namespace XSLT OUString XSLTFilter::expandUrl(const OUString& sUrl) { - OUString sExpandedUrl; try { + OUString sPreparedURL(sUrl); + if (sPreparedURL.startsWithIgnoreAsciiCase("vnd.sun.star.expand:", &sPreparedURL)) + sPreparedURL = rtl::Uri::decode(sPreparedURL, rtl_UriDecodeWithCharset, + RTL_TEXTENCODING_UTF8); css::uno::Reference<XMacroExpander> xMacroExpander = theMacroExpander::get(m_xContext); - sExpandedUrl = xMacroExpander->expandMacros(sUrl); - sal_Int32 nPos = sExpandedUrl.indexOf( "vnd.sun.star.expand:" ); - if (nPos != -1) - sExpandedUrl = sExpandedUrl.copy(nPos + 20); + return xMacroExpander->expandMacros(sPreparedURL); } catch (const Exception&) { } - return sExpandedUrl; + return {}; } css::uno::Reference<xslt::XXSLTTransformer> diff --git a/scripting/source/basprov/basprov.cxx b/scripting/source/basprov/basprov.cxx index d4afb41eaea3..cafd4daa76d0 100644 --- a/scripting/source/basprov/basprov.cxx +++ b/scripting/source/basprov/basprov.cxx @@ -103,10 +103,9 @@ namespace basprov } else if ( aScheme.equalsIgnoreAsciiCase("vnd.sun.star.pkg") ) { - OUString aAuthority = xUriRef->getAuthority(); - if ( aAuthority.matchIgnoreAsciiCase( "vnd.sun.star.expand:" ) ) + OUString aDecodedURL = xUriRef->getAuthority(); + if ( aDecodedURL.startsWithIgnoreAsciiCase( "vnd.sun.star.expand:", &aDecodedURL ) ) { - OUString aDecodedURL( aAuthority.copy( sizeof ( "vnd.sun.star.expand:" ) - 1 ) ); aDecodedURL = ::rtl::Uri::decode( aDecodedURL, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); Reference<util::XMacroExpander> xMacroExpander = util::theMacroExpander::get(m_xContext); 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 ); } } diff --git a/ucb/source/ucp/expand/ucpexpand.cxx b/ucb/source/ucp/expand/ucpexpand.cxx index cf4664ffbf65..829649ab8955 100644 --- a/ucb/source/ucp/expand/ucpexpand.cxx +++ b/ucb/source/ucp/expand/ucpexpand.cxx @@ -30,8 +30,6 @@ #include <com/sun/star/ucb/XContentProvider.hpp> #include <comphelper/diagnose_ex.hxx> -#define EXPAND_PROTOCOL "vnd.sun.star.expand" - using namespace ::com::sun::star; @@ -114,18 +112,15 @@ OUString ExpandContentProviderImpl::expandUri( uno::Reference< ucb::XContentIdentifier > const & xIdentifier ) const { OUString uri( xIdentifier->getContentIdentifier() ); - if (!uri.startsWith(EXPAND_PROTOCOL ":")) + if (!uri.startsWithIgnoreAsciiCase("vnd.sun.star.expand:", &uri)) { throw ucb::IllegalIdentifierException( - "expected protocol " EXPAND_PROTOCOL "!", + "expected protocol vnd.sun.star.expand!", static_cast< OWeakObject * >( const_cast< ExpandContentProviderImpl * >(this) ) ); } - // cut protocol - OUString str( uri.copy( sizeof (EXPAND_PROTOCOL ":") -1 ) ); // decode uric class chars - str = ::rtl::Uri::decode( - str, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 ); + OUString str = ::rtl::Uri::decode(uri, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8); // expand macro string return m_xMacroExpander->expandMacros( str ); } diff --git a/wizards/com/sun/star/wizards/common/FileAccess.java b/wizards/com/sun/star/wizards/common/FileAccess.java index 1dfb3c90d6b5..4e8d520a529f 100644 --- a/wizards/com/sun/star/wizards/common/FileAccess.java +++ b/wizards/com/sun/star/wizards/common/FileAccess.java @@ -21,6 +21,7 @@ import com.sun.star.beans.XPropertySet; import com.sun.star.lang.Locale; import com.sun.star.uno.Exception; import com.sun.star.util.XMacroExpander; +import java.net.URLDecoder; import java.util.ArrayList; import java.util.Arrays; import java.util.Vector; @@ -29,6 +30,7 @@ import com.sun.star.io.XActiveDataSink; import com.sun.star.io.XInputStream; import com.sun.star.io.XTextInputStream; import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lib.util.StringHelper; import com.sun.star.ucb.CommandAbortedException; import com.sun.star.ucb.XFileIdentifierConverter; import com.sun.star.ucb.XSimpleFileAccess; @@ -184,9 +186,11 @@ public class FileAccess for (int i = 0; i < Template_internal.length; i++) { String sPath = Template_internal[i]; - if (sPath.startsWith("vnd.")) + if (sPath.toLowerCase().startsWith("vnd.sun.star.expand:")) { - String sPathToExpand = sPath.substring("vnd.sun.star.Expand:".length()); + String sPathToExpand = URLDecoder.decode(StringHelper.replace( + sPath.substring("vnd.sun.star.expand:".length()), + '+', "%2B"), "UTF-8"); XMacroExpander xExpander = Helper.getMacroExpander(xMSF); sPath = xExpander.expandMacros(sPathToExpand); @@ -201,7 +205,7 @@ public class FileAccess aPathList.add(Template_writable); // There was a bug here, because we have to search through the whole list of paths } - catch (Exception exception) + catch (java.lang.Exception exception) { exception.printStackTrace(System.err); } |