lint
This commit is contained in:
parent
539db70fd5
commit
a320fc6f7a
74
src/Config.h
74
src/Config.h
@ -25,39 +25,46 @@ constexpr auto LABEL_MEDIUM_SIZE_RATIO = 1.3;
|
|||||||
|
|
||||||
namespace strings {
|
namespace strings {
|
||||||
const QString url_html = QStringLiteral("<a href=\"\\1\">\\1</a>");
|
const QString url_html = QStringLiteral("<a href=\"\\1\">\\1</a>");
|
||||||
const QRegularExpression url_regex(
|
const QRegularExpression
|
||||||
|
url_regex(
|
||||||
// match an unquoted URL
|
// match an unquoted URL
|
||||||
[](){
|
[]() {
|
||||||
const auto
|
const auto general_unicode = QStringLiteral(
|
||||||
general_unicode = QStringLiteral(R"((?:[^\x{0}-\x{7f}\p{Cc}\s\p{P}]|[\x{2010}\x{2011}\x{2012}\x{2013}\x{2014}\x{2015}]))"),
|
R"((?:[^\x{0}-\x{7f}\p{Cc}\s\p{P}]|[\x{2010}\x{2011}\x{2012}\x{2013}\x{2014}\x{2015}]))");
|
||||||
protocol = QStringLiteral(R"((?:[Hh][Tt][Tt][Pp][Ss]?))"),
|
const auto protocol = QStringLiteral(R"((?:[Hh][Tt][Tt][Pp][Ss]?))");
|
||||||
unreserved_subdelims_colon = QStringLiteral(R"([a-zA-Z0-9\-._~!$&'()*+,;=:])"),
|
const auto unreserved_subdelims_colon = QStringLiteral(R"([a-zA-Z0-9\-._~!$&'()*+,;=:])");
|
||||||
pct_enc = QStringLiteral(R"((?:%[[:xdigit:]]{2}))"),
|
const auto pct_enc = QStringLiteral(R"((?:%[[:xdigit:]]{2}))");
|
||||||
userinfo = "(?:" + unreserved_subdelims_colon + "*(?:" + pct_enc + unreserved_subdelims_colon + "*)*)",
|
const auto userinfo = "(?:" + unreserved_subdelims_colon + "*(?:" + pct_enc +
|
||||||
dec_octet = QStringLiteral(R"((?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9]))"),
|
unreserved_subdelims_colon + "*)*)";
|
||||||
ipv4_addr = "(?:" + dec_octet + R"((?:\.)" + dec_octet + "){3})",
|
const auto dec_octet =
|
||||||
h16 = QStringLiteral(R"((?:[[:xdigit:]]{1,4}))"),
|
QStringLiteral(R"((?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9]))");
|
||||||
ls32 = "(?:" + h16 + ":" + h16 + "|" + ipv4_addr + ")",
|
const auto ipv4_addr = "(?:" + dec_octet + R"((?:\.)" + dec_octet + "){3})";
|
||||||
ipv6_addr = "(?:"
|
const auto h16 = QStringLiteral(R"((?:[[:xdigit:]]{1,4}))");
|
||||||
"(?:" + h16 + ":){6}" + ls32
|
const auto ls32 = "(?:" + h16 + ":" + h16 + "|" + ipv4_addr + ")";
|
||||||
+ "|" "::(?:" + h16 + ":){5}" + ls32
|
// clang-format off
|
||||||
+ "|" + h16 + "?::(?:" + h16 + ":){4}" + ls32
|
const auto ipv6_addr = "(?:"
|
||||||
+ "|" "(?:" + h16 + "(?::" + h16 + "){0,1})?::(?:" + h16 + ":){3}" + ls32
|
"(?:" + h16 + ":){6}" + ls32
|
||||||
+ "|" "(?:" + h16 + "(?::" + h16 + "){0,2})?::(?:" + h16 + ":){2}" + ls32
|
+ "|" "::(?:" + h16 + ":){5}" + ls32
|
||||||
+ "|" "(?:" + h16 + "(?::" + h16 + "){0,3})?::" + h16 + ":" + ls32
|
+ "|" + h16 + "?::(?:" + h16 + ":){4}" + ls32
|
||||||
+ "|" "(?:" + h16 + "(?::" + h16 + "){0,4})?::" + ls32
|
+ "|" "(?:" + h16 + "(?::" + h16 + "){0,1})?::(?:" + h16 + ":){3}" + ls32
|
||||||
+ "|" "(?:" + h16 + "(?::" + h16 + "){0,5})?::" + h16
|
+ "|" "(?:" + h16 + "(?::" + h16 + "){0,2})?::(?:" + h16 + ":){2}" + ls32
|
||||||
+ "|" "(?:" + h16 + "(?::" + h16 + "){0,6})?::"
|
+ "|" "(?:" + h16 + "(?::" + h16 + "){0,3})?::" + h16 + ":" + ls32
|
||||||
")",
|
+ "|" "(?:" + h16 + "(?::" + h16 + "){0,4})?::" + ls32
|
||||||
ipvfuture = R"((?:v[[:xdigit:]]+\.)" + unreserved_subdelims_colon + "+)",
|
+ "|" "(?:" + h16 + "(?::" + h16 + "){0,5})?::" + h16
|
||||||
ip_literal = R"((?:\[(?:)" + ipv6_addr + "|" + ipvfuture + R"()\]))",
|
+ "|" "(?:" + h16 + "(?::" + h16 + "){0,6})?::"
|
||||||
host_alnum = "(?:[a-zA-Z0-9]|" + general_unicode + ")",
|
")";
|
||||||
host_label = "(?:" + host_alnum + "+(?:-+" + host_alnum + "+)*)",
|
// clang-format on
|
||||||
hostname = "(?:" + host_label + R"((?:\.)" + host_label + R"()*\.?))",
|
const auto ipvfuture = R"((?:v[[:xdigit:]]+\.)" + unreserved_subdelims_colon + "+)";
|
||||||
host = "(?:" + hostname + "|" + ip_literal + ")",
|
const auto ip_literal = R"((?:\[(?:)" + ipv6_addr + "|" + ipvfuture + R"()\]))";
|
||||||
path = R"((?:/((?:[a-zA-Z0-9\-._~!$&'*+,;=:@/]|)" + pct_enc + R"(|\((?-1)\)|)" + general_unicode + ")*))",
|
const auto host_alnum = "(?:[a-zA-Z0-9]|" + general_unicode + ")";
|
||||||
query = R"(((?:[a-zA-Z0-9\-._~!$&'*+,;=:@/?\\{}]|)" + pct_enc + R"(|\((?-1)\)|\[(?-1)\]|)" + general_unicode + ")*)",
|
const auto host_label = "(?:" + host_alnum + "+(?:-+" + host_alnum + "+)*)";
|
||||||
fragment = query;
|
const auto hostname = "(?:" + host_label + R"((?:\.)" + host_label + R"()*\.?))";
|
||||||
|
const auto host = "(?:" + hostname + "|" + ip_literal + ")";
|
||||||
|
const auto path = R"((?:/((?:[a-zA-Z0-9\-._~!$&'*+,;=:@/]|)" + pct_enc + R"(|\((?-1)\)|)" +
|
||||||
|
general_unicode + ")*))";
|
||||||
|
const auto query = R"(((?:[a-zA-Z0-9\-._~!$&'*+,;=:@/?\\{}]|)" + pct_enc +
|
||||||
|
R"(|\((?-1)\)|\[(?-1)\]|)" + general_unicode + ")*)";
|
||||||
|
const auto &fragment = query;
|
||||||
return
|
return
|
||||||
R"((?<!["'\w])(?>()"
|
R"((?<!["'\w])(?>()"
|
||||||
+ protocol + "://"
|
+ protocol + "://"
|
||||||
@ -69,8 +76,7 @@ const QRegularExpression url_regex(
|
|||||||
"(?<![.!?,;:'])"
|
"(?<![.!?,;:'])"
|
||||||
R"())(?!["']))";
|
R"())(?!["']))";
|
||||||
}(),
|
}(),
|
||||||
QRegularExpression::UseUnicodePropertiesOption
|
QRegularExpression::UseUnicodePropertiesOption);
|
||||||
);
|
|
||||||
// A matrix link to be converted back to markdown
|
// A matrix link to be converted back to markdown
|
||||||
static const QRegularExpression
|
static const QRegularExpression
|
||||||
matrixToLink(QStringLiteral(R"(<a href=\"(https://matrix.to/#/.*?)\">(.*?)</a>)"));
|
matrixToLink(QStringLiteral(R"(<a href=\"(https://matrix.to/#/.*?)\">(.*?)</a>)"));
|
||||||
|
Loading…
Reference in New Issue
Block a user