diff --git a/autotests/ktexttohtmltest.cpp b/autotests/ktexttohtmltest.cpp
--- a/autotests/ktexttohtmltest.cpp
+++ b/autotests/ktexttohtmltest.cpp
@@ -423,7 +423,7 @@
//Bug 346132
QTest::newRow("url-with-ref-in-<") << "http://www.foo.bar"
<< KTextToHTML::Options(KTextToHTML::PreserveSpaces)
- << "http://www.foo.bar[1]";
+ << "http://www.foo.bar<http://foo.bar/>";
QTest::newRow("url-with-ref-in-]") << "[Please visit our booth 24-25 http://example.com/]"
<< KTextToHTML::Options(KTextToHTML::PreserveSpaces)
@@ -440,9 +440,6 @@
QEXPECT_FAIL("punctation-bug", "Linklocator does not properly detect punctation as boundaries",
Continue);
- QEXPECT_FAIL("url-with-ref-in-<", "Linklocator does not properly parse url with <",
- Continue);
-
QString actualHtml = KTextToHTML::convertToHtml(plainText, flags);
QCOMPARE(actualHtml, htmlText);
}
diff --git a/src/lib/text/ktexttohtml.cpp b/src/lib/text/ktexttohtml.cpp
--- a/src/lib/text/ktexttohtml.cpp
+++ b/src/lib/text/ktexttohtml.cpp
@@ -234,6 +234,18 @@
(mText[mPos].isPrint() || mText[mPos].isSpace()) &&
((afterUrl.isNull() && !mText[mPos].isSpace()) ||
(!afterUrl.isNull() && mText[mPos] != afterUrl))) {
+ if (!previousCharIsSpace && (mText[mPos] == QLatin1Char('<')) && ((mPos + 1) < mText.length())) {
+ // Fix Bug #346132: allow "http://www.foo.bar"
+ // < inside a URL is not allowed, however there is a test which
+ // checks that "http://some/path" should be allowed
+ // Therefore: check if what follows is another URL and if so, stop here
+ mPos++;
+ if (atUrl()) {
+ mPos--;
+ break;
+ }
+ mPos--;
+ }
if (mText[mPos].isSpace()) {
previousCharIsSpace = true;
} else if (!previousIsAnAnchor && mText[mPos] == QLatin1Char('[')) {