diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-02-13 11:22:03 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-02-13 11:29:34 +0000 |
commit | 00f6c36b603416b73e1327ac4c862b1eaca2d277 (patch) | |
tree | e9004fd7ae4ea91a9d8908fe86ea0e0d97801bef /ucb/source | |
parent | b926ba60d11cb78b4e042e2abb2d00dde128a1f8 (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 'ucb/source')
-rw-r--r-- | ucb/source/ucp/expand/ucpexpand.cxx | 11 |
1 files changed, 3 insertions, 8 deletions
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 ); } |