fix: count parentheses in links (#5515)

This commit is contained in:
nerix
2024-07-21 16:00:12 +02:00
committed by GitHub
parent 5deec1f02f
commit 847e4f0932
4 changed files with 60 additions and 11 deletions
+14 -5
View File
@@ -23,8 +23,8 @@ struct Case {
"", "_", "__", "<", "<<", "<_<", "(((", "<*_~(", "**", "~~",
};
QStringList suffixes{
"", ">", "?", "!", ".", ",", ":",
"*", "~", ">>", "?!.", "~~,*!?", "**",
"", ">", "?", "!", ".", ",", ":", "*", "~",
">>", "?!.", "~~,*!?", "**", ").", "),", ",)", ")),.", ")?",
};
for (const auto &prefix : prefixes)
@@ -89,14 +89,21 @@ TEST(LinkParser, parseDomainLinks)
{"", "https.cat"},
{"", "httpsd.cat"},
{"", "http.cat", "/200"},
{"", "http.cat", "/200("},
{"", "a.com", "?("},
{"", "a.com", "#("},
{"", "http.cat", "/200()"},
{"", "a.com", "?()"},
{"", "a.com", "#()"},
{"", "a.com", "/__my_user__"},
{"", "a.b.c.-._.1.com", ""},
{"", "0123456789.com", ""},
{"", "ABCDEFGHIJKLMNOPQRSTUVWXYZ.com", ""},
{"", "abcdefghijklmnopqrstuvwxyz.com", ""},
{"", "example.com", "/foo(bar)"},
{"", "example.com", "/foo((bar))"},
{"", "example.com", "/(f)(o)(o)(b)(a)r"},
{"", "example.com", "/foobar()()"},
{"", "example.com", "/foobar()(())baz"},
{"", "example.com", "/(foo)"},
{"", "example.com", "/()"},
// non-ASCII characters are allowed
{"", u"köln.de"_s, ""},
{"", u"ü.com"_s, ""},
@@ -246,6 +253,8 @@ TEST(LinkParser, doesntParseInvalidLinks)
"@@@.com",
"%%%.com",
"*.com",
"example.com(foo)",
"example.com()",
};
for (const auto &input : inputs)