From ebdf955e48db51b3cc2fa6279c5cfb5094112602 Mon Sep 17 00:00:00 2001 From: Montel Laurent Date: Tue, 17 Jan 2017 07:41:53 +0100 Subject: [PATCH] Fix Bug 363427 - unsafe characters incorrectly parsed as part of URL Fix [Please visit our booth 24-25 http://example.com/] CCBUG:363427 Gbp-Pq: Name Fix-Bug-363427-unsafe-characters-incorrectly-parsed-as-pa.patch --- autotests/ktexttohtmltest.cpp | 8 ++++++++ src/lib/text/ktexttohtml.cpp | 2 ++ 2 files changed, 10 insertions(+) diff --git a/autotests/ktexttohtmltest.cpp b/autotests/ktexttohtmltest.cpp index f48a31c..0c14623 100644 --- a/autotests/ktexttohtmltest.cpp +++ b/autotests/ktexttohtmltest.cpp @@ -416,6 +416,14 @@ void KTextToHTMLTest::testHtmlConvert_data() QTest::newRow("url-with-ref-in-[") << "https://www.kde.org[1]" << KTextToHTML::Options(KTextToHTML::PreserveSpaces) << "https://www.kde.org[1]"; + + QTest::newRow("url-with-ref-in-[2") << "[http://www.example.org/][whatever]" + << KTextToHTML::Options(KTextToHTML::PreserveSpaces) + << "[http://www.example.org/][whatever]"; + + QTest::newRow("url-with-ref-in-]") << "[Please visit our booth 24-25 http://example.com/]" + << KTextToHTML::Options(KTextToHTML::PreserveSpaces) + << "[Please visit our booth 24-25 http://example.com/]"; } diff --git a/src/lib/text/ktexttohtml.cpp b/src/lib/text/ktexttohtml.cpp index ecc1d22..d6c1f1c 100644 --- a/src/lib/text/ktexttohtml.cpp +++ b/src/lib/text/ktexttohtml.cpp @@ -238,6 +238,8 @@ QString KTextToHTMLHelper::getUrl(bool *badurl) previousCharIsSpace = true; } else if (!previousIsAnAnchor && mText[mPos] == QLatin1Char('[')) { break; + } else if (!previousIsAnAnchor && mText[mPos] == QLatin1Char(']')) { + break; } else { // skip whitespace if (previousCharIsSpace && mText[mPos] == QLatin1Char('<')) { url.append(QLatin1Char(' ')); -- 2.30.2