Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Leap:42.2:Update
kcoreaddons
0001-Fix-very-old-bug-when-we-remove-space-in-u...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-Fix-very-old-bug-when-we-remove-space-in-url-as-foo-.patch of Package kcoreaddons
From 5d661f9c1e384402814f4488881059ef79a0f0c8 Mon Sep 17 00:00:00 2001 From: Montel Laurent <montel@kde.org> Date: Wed, 21 Sep 2016 07:24:30 +0200 Subject: [PATCH 1/2] Fix very old bug when we remove space in url as "foo <<url> <url>>" (cherry picked from commit 1be7272373d60e4234f1a5584e676b579302b053) --- autotests/ktexttohtmltest.cpp | 14 ++++++++++++++ src/lib/text/ktexttohtml.cpp | 14 ++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/autotests/ktexttohtmltest.cpp b/autotests/ktexttohtmltest.cpp index 474f0ca..8fc0c56 100644 --- a/autotests/ktexttohtmltest.cpp +++ b/autotests/ktexttohtmltest.cpp @@ -30,6 +30,15 @@ QTEST_MAIN(KTextToHTMLTest) Q_DECLARE_METATYPE(KTextToHTML::Options) +#ifndef Q_OS_WIN +void initLocale() +{ + setenv("LC_ALL", "en_US.utf-8", 1); +} +Q_CONSTRUCTOR_FUNCTION(initLocale) +#endif + + void KTextToHTMLTest::testGetEmailAddress() { // empty input @@ -372,6 +381,11 @@ void KTextToHTMLTest::testHtmlConvert_data() QTest::newRow("url-in-parenthesis-3") << "bla (http://www.kde.org - section 5.2)" << KTextToHTML::Options(KTextToHTML::PreserveSpaces) << "bla (<a href=\"http://www.kde.org\">http://www.kde.org</a> - section 5.2)"; + + // Fix url as foo <<url> <url>> when we concatened them. + QTest::newRow("url-with-url") << "foo <http://www.kde.org/ <http://www.kde.org/>>" + << KTextToHTML::Options(KTextToHTML::PreserveSpaces) + << "foo <<a href=\"http://www.kde.org/ \">http://www.kde.org/ </a><<a href=\"http://www.kde.org/\">http://www.kde.org/</a>>>"; } diff --git a/src/lib/text/ktexttohtml.cpp b/src/lib/text/ktexttohtml.cpp index 8ed923d..b181f56 100644 --- a/src/lib/text/ktexttohtml.cpp +++ b/src/lib/text/ktexttohtml.cpp @@ -228,11 +228,19 @@ QString KTextToHTMLHelper::getUrl() url.reserve(mMaxUrlLen); // avoid allocs int start = mPos; + bool previousCharIsSpace = false; while ((mPos < mText.length()) && (mText[mPos].isPrint() || mText[mPos].isSpace()) && ((afterUrl.isNull() && !mText[mPos].isSpace()) || (!afterUrl.isNull() && mText[mPos] != afterUrl))) { - if (!mText[mPos].isSpace()) { // skip whitespace + if (mText[mPos].isSpace()) { + previousCharIsSpace = true; + } else { // skip whitespace + if (previousCharIsSpace && mText[mPos] == QLatin1Char('<')) { + url.append(QLatin1Char(' ')); + break; + } + previousCharIsSpace = false; url.append(mText[mPos]); if (url.length() > mMaxUrlLen) { break; @@ -267,7 +275,6 @@ QString KTextToHTMLHelper::getUrl() } } while (url.length() > 1); } - return url; } @@ -334,6 +341,7 @@ QString KTextToHTML::convertToHtml(const QString &plainText, const KTextToHTML:: QChar ch; int x; bool startOfLine = true; + //qDebug()<<" plainText"<<plainText; for (helper.mPos = 0, x = 0; helper.mPos < helper.mText.length(); ++helper.mPos, ++x) { @@ -402,6 +410,7 @@ QString KTextToHTML::convertToHtml(const QString &plainText, const KTextToHTML:: const int start = helper.mPos; if (!(flags & IgnoreUrls)) { str = helper.getUrl(); + //qDebug()<<" str"<<str; if (!str.isEmpty()) { QString hyperlink; if (str.left(4) == QLatin1String("www.")) { @@ -455,6 +464,7 @@ QString KTextToHTML::convertToHtml(const QString &plainText, const KTextToHTML:: result = helper.emoticonsInterface()->parseEmoticons(result, true, exclude); } + //qDebug()<<" result "<<result; return result; } -- 2.10.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor