diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-02-07 15:34:33 +0100 |
---|---|---|
committer | Thorsten Behrens <Thorsten.Behrens@CIB.de> | 2020-02-12 00:23:24 +0100 |
commit | 6ce74c39d15a9e55cc2ad846e18e001509e95392 (patch) | |
tree | b8b728d4ed7ca528696afe55d2b995327503ea1b /svl | |
parent | related: tdf#106742 sw: DOCX import/export: fix default of table indent (diff) | |
download | core-6ce74c39d15a9e55cc2ad846e18e001509e95392.tar.gz core-6ce74c39d15a9e55cc2ad846e18e001509e95392.zip |
tdf#130501: Fix off-by-one error in URIHelper::resolveIdnaHost
Change-Id: Ibc231308d0fc93085933ae7d80dc8c4b2699fe02
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88204
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
(cherry picked from commit 4c0394461af4d6bcba059161113abffbb484efe8)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88295
Reviewed-by: Michael Stahl <michael.stahl@cib.de>
(cherry picked from commit 289d2e5c86ffa99bc6a8c6c51f630d629afcd954)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88401
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/qa/unit/test_URIHelper.cxx | 13 | ||||
-rw-r--r-- | svl/source/misc/urihelper.cxx | 10 |
2 files changed, 19 insertions, 4 deletions
diff --git a/svl/qa/unit/test_URIHelper.cxx b/svl/qa/unit/test_URIHelper.cxx index 233b812a54c7..6f749fc6194b 100644 --- a/svl/qa/unit/test_URIHelper.cxx +++ b/svl/qa/unit/test_URIHelper.cxx @@ -468,6 +468,19 @@ void Test::testResolveIdnaHost() { CPPUNIT_ASSERT_EQUAL( OUString("foo://xn--mnchen-3ya.de"), URIHelper::resolveIdnaHost(u"foo://Mu\u0308nchen.de")); + + CPPUNIT_ASSERT_EQUAL( + OUString("foo://example.xn--m-eha"), URIHelper::resolveIdnaHost(u"foo://example.mü")); + + CPPUNIT_ASSERT_EQUAL( + OUString("foo://example.xn--m-eha:0"), URIHelper::resolveIdnaHost(u"foo://example.mü:0")); + + CPPUNIT_ASSERT_EQUAL( + OUString("foo://xn--e1afmkfd.xn--p1ai"), URIHelper::resolveIdnaHost(u"foo://пример.рф")); + + CPPUNIT_ASSERT_EQUAL( + OUString("foo://xn--e1afmkfd.xn--p1ai:0"), + URIHelper::resolveIdnaHost(u"foo://пример.рф:0")); } css::uno::Reference< css::uno::XComponentContext > Test::m_context; diff --git a/svl/source/misc/urihelper.cxx b/svl/source/misc/urihelper.cxx index dc60dee5f73f..5f569fdd5cec 100644 --- a/svl/source/misc/urihelper.cxx +++ b/svl/source/misc/urihelper.cxx @@ -743,12 +743,14 @@ OUString URIHelper::resolveIdnaHost(OUString const & url) { if (auth.isEmpty()) return url; sal_Int32 hostStart = auth.indexOf('@') + 1; - sal_Int32 hostEnd = auth.getLength() - 1; - while (hostEnd > hostStart && rtl::isAsciiDigit(auth[hostEnd])) { + sal_Int32 hostEnd = auth.getLength(); + while (hostEnd > hostStart && rtl::isAsciiDigit(auth[hostEnd - 1])) { --hostEnd; } - if (!(hostEnd > hostStart && auth[hostEnd] == ':')) { - hostEnd = auth.getLength() - 1; + if (hostEnd > hostStart && auth[hostEnd - 1] == ':') { + --hostEnd; + } else { + hostEnd = auth.getLength(); } auto asciiOnly = true; for (auto i = hostStart; i != hostEnd; ++i) { |