Commit 013cf65c authored by Luis Javier Merino's avatar Luis Javier Merino Committed by Ahmad Samir
Browse files

url filter: do not allow parenthesis in hostname

parent e925acc1
Pipeline #198080 passed with stage
in 4 minutes and 57 seconds
......@@ -88,8 +88,8 @@ void HotSpotFilterTest::testUrlFilterRegex_data()
<< "http://en.wikipedia.org/w/index.php?title=Thresholding_(image_processing)&oldid=132306976" << true;
QTest::newRow("fragment_with_parens") << "https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_(Control_Sequence_Introducer)_sequences"
<< "https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_(Control_Sequence_Introducer)_sequences" << true;
QTest::newRow("url_with_lots_of_parens") << "(https://foo(bar(baz(qux)quux)quuux))))"
<< "https://foo(bar(baz(qux)quux)quuux)" << true;
QTest::newRow("url_with_lots_of_parens") << "(https://example.com/foo(bar(baz(qux)quux)quuux))))"
<< "https://example.com/foo(bar(baz(qux)quux)quuux)" << true;
}
void HotSpotFilterTest::testUrlFilterRegex()
......
......@@ -31,7 +31,8 @@ using namespace Konsole;
// - "port" (':1234'), if present, is assumed to be non-empty
// - We don't check the validity of percent-encoded characters
// (e.g. "www.example.com/foo%XXbar")
// - We don't recognize URIs with unbalanced parens in regname, path, query or fragment.
// - We do not allow parenthesis in host.
// - We don't recognize URIs with unbalanced parens in path, query or fragment.
// We do this to prevent URIs inside parentheses from getting extended to the closing
// parenthesis. We still recognize unbalanced parens in userInfo, but the
// postfix @ should prevent most ambiguity.
......@@ -52,7 +53,7 @@ static const char scheme_or_www_end[] = ")";
/* clang-format off */
static const char userInfo[] = "(?:[" COMMON_1 ":()" "]++@)?+"; // user:password@
#define IPv6_literal "\\[[0-9a-fA-F:.]++\\]"
static const char host[] = "(?:" BALANCED_PARENS(COMMON_1) "++|" IPv6_literal ")?+"; // www.foo.bar
static const char host[] = "(?:[" COMMON_1 "]++|" IPv6_literal ")?+"; // www.foo.bar
static const char port[] = "(?::[0-9]+)?+"; // :1234
#define COMMON_2 "a-z0-9\\-._~%!$&'*+,;=:@/"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment