diff --git a/src/autotests/HotSpotFilterTest.cpp b/src/autotests/HotSpotFilterTest.cpp index d85f1932..28b59512 100644 --- a/src/autotests/HotSpotFilterTest.cpp +++ b/src/autotests/HotSpotFilterTest.cpp @@ -63,6 +63,9 @@ void HotSpotFilterTest::testUrlFilterRegex_data() << "http://example.com" << true; QTest::newRow("empty_fragment") << "http://example.com/#" << "http://example.com" << true; + + QTest::newRow("www_followed_by_colon") << "www.example.com:foo@bar.com" + << "www.example.com" << true; } void HotSpotFilterTest::testUrlFilterRegex() diff --git a/src/filterHotSpots/UrlFilter.cpp b/src/filterHotSpots/UrlFilter.cpp index e93b9b41..86acd8c0 100644 --- a/src/filterHotSpots/UrlFilter.cpp +++ b/src/filterHotSpots/UrlFilter.cpp @@ -37,7 +37,8 @@ using namespace Konsole; // scheme:// // - Must start with an ASCII letter, preceeded by any non-word character, // so "http" but not "mhttp" -static const char scheme_or_www[] = "(?<=^|[\\s\\[\\]()'\"])(?:www\\.|[a-z][a-z0-9+\\-.]*+://)"; +static const char scheme_or_www[] = "(?<=^|[\\s\\[\\]()'\"])(?:www\\.|[a-z][a-z0-9+\\-.]*+://"; +static const char scheme_or_www_end[] = ")"; // unreserved / pct-encoded / sub-delims #define COMMON_1 "a-z0-9\\-._~%!$&'()*+,;=" @@ -62,6 +63,7 @@ using LS1 = QLatin1String; const QRegularExpression UrlFilter::FullUrlRegExp( LS1(scheme_or_www) + LS1(userInfo) + + LS1(scheme_or_www_end) + LS1(host) + LS1(port) + LS1(path)