svl/qa/unit/test_URIHelper.cxx | 13 +++++++++++++ svl/source/misc/urihelper.cxx | 10 ++++++---- 2 files changed, 19 insertions(+), 4 deletions(-)
New commits: commit 289d2e5c86ffa99bc6a8c6c51f630d629afcd954 Author: Stephan Bergmann <sberg...@redhat.com> AuthorDate: Fri Feb 7 15:34:33 2020 +0100 Commit: Michael Stahl <michael.st...@cib.de> CommitDate: Mon Feb 10 13:51:59 2020 +0100 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 <sberg...@redhat.com> (cherry picked from commit 4c0394461af4d6bcba059161113abffbb484efe8) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88295 Reviewed-by: Michael Stahl <michael.st...@cib.de> diff --git a/svl/qa/unit/test_URIHelper.cxx b/svl/qa/unit/test_URIHelper.cxx index 11b7d0359b2a..5954bcd39289 100644 --- a/svl/qa/unit/test_URIHelper.cxx +++ b/svl/qa/unit/test_URIHelper.cxx @@ -463,6 +463,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 62177ac79e25..127134d1ab72 100644 --- a/svl/source/misc/urihelper.cxx +++ b/svl/source/misc/urihelper.cxx @@ -742,12 +742,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) { _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits