summaryrefslogtreecommitdiff
path: root/sw/source/core
diff options
context:
space:
mode:
authorMichael Stahl <michael.stahl@allotropia.de>2021-02-03 20:05:15 +0100
committerMichael Stahl <michael.stahl@allotropia.de>2021-02-05 11:41:52 +0100
commit7f14ea4431cb4182bccbd9998a60db2f9d9ae07a (patch)
treecf58dfe91ac4a2290fdfda4085c212779a37576b /sw/source/core
parent8b15deceaa54ed20c2ce4199cd54baaec26ae2c2 (diff)
(related: tdf#121842) sw: encode URLs generated in ToX
The "|" is used as a separator there and it looks like it has never been allowed in a URI, even in a fragment. Change-Id: I1e4b9e12f5409f93c2291494fd4350431f68fe2b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/110388 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
Diffstat (limited to 'sw/source/core')
-rw-r--r--sw/source/core/tox/ToxLinkProcessor.cxx10
-rw-r--r--sw/source/core/tox/txmsrt.cxx6
2 files changed, 10 insertions, 6 deletions
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 <SwStyleNameMapper.hxx>
#include <ndtxt.hxx>
#include <sal/log.hxx>
+#include <rtl/uri.hxx>
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<ClosedLink> 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 <unotools/charclass.hxx>
#include <osl/diagnose.h>
-#include <rtl/uri.hxx>
#include <txtfld.hxx>
#include <doc.hxx>
#include <IDocumentLayoutAccess.hxx>
@@ -204,10 +203,7 @@ std::pair<OUString, bool> 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