diff --git a/sw/qa/core/test_ToxLinkProcessor.cxx b/sw/qa/core/test_ToxLinkProcessor.cxx index 9b690be4211a..cd18f453db87 100644 --- a/sw/qa/core/test_ToxLinkProcessor.cxx +++ b/sw/qa/core/test_ToxLinkProcessor.cxx @@ -44,8 +44,8 @@ public: static constexpr OUStringLiteral STYLE_NAME_2 = u"anyStyle2"; static const sal_uInt16 POOL_ID_1; static const sal_uInt16 POOL_ID_2; - static constexpr OUStringLiteral URL_1 = u"anyUrl1"; - static constexpr OUStringLiteral URL_2 = u"anyUrl2"; + static constexpr OUStringLiteral URL_1 = u"#anyUrl1"; + static constexpr OUStringLiteral URL_2 = u"#anyUrl2"; }; const sal_uInt16 ToxLinkProcessorTest::POOL_ID_1 = 42; diff --git a/sw/source/core/tox/ToxLinkProcessor.cxx b/sw/source/core/tox/ToxLinkProcessor.cxx index c86cde923fef..825e37c16f65 100644 --- a/sw/source/core/tox/ToxLinkProcessor.cxx +++ b/sw/source/core/tox/ToxLinkProcessor.cxx @@ -13,6 +13,7 @@ #include #include #include +#include namespace sw { @@ -37,8 +38,15 @@ ToxLinkProcessor::CloseLink(sal_Int32 endPosition, const OUString& url) return; } + // url contains '|' which must be encoded; also in some cases contains + // arbitrary strings that need to be encoded + assert(url[0] == '#'); // all links are internal + OUString const uri("#" + rtl::Uri::encode(url.copy(1), + rtl_UriCharClassUricNoSlash, + rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8)); + std::unique_ptr pClosedLink( - new ClosedLink(url, m_pStartedLink->mStartPosition, endPosition)); + new ClosedLink(uri, m_pStartedLink->mStartPosition, endPosition)); const OUString& characterStyle = m_pStartedLink->mCharacterStyle; sal_uInt16 poolId = ObtainPoolId(characterStyle); diff --git a/sw/source/core/tox/txmsrt.cxx b/sw/source/core/tox/txmsrt.cxx index f626f09afc40..3bdd2871c23c 100644 --- a/sw/source/core/tox/txmsrt.cxx +++ b/sw/source/core/tox/txmsrt.cxx @@ -19,7 +19,6 @@ #include #include -#include #include #include #include @@ -204,10 +203,7 @@ std::pair SwTOXSortTabBase::GetURL(SwRootFrame const*const pLayo + OUStringChar(toxMarkSeparator) + typeName + OUStringChar(cMarkSeparator) + "toxmark" ); - OUString const uri(rtl::Uri::encode(decodedUrl, rtl_UriCharClassUricNoSlash, - rtl_UriEncodeIgnoreEscapes, RTL_TEXTENCODING_UTF8)); - - return std::make_pair(uri, true); + return std::make_pair(decodedUrl, true); } bool SwTOXSortTabBase::IsFullPara() const