From 848253b015e5d464773a5810f46276f194545cac Mon Sep 17 00:00:00 2001 From: Lajamerr Mittesdine Date: Tue, 5 Jun 2018 06:19:35 -0400 Subject: [PATCH] RFC Compliant URL Matching Implemented https://gist.github.com/dperini/729294 in Chatterino 2. This makes URL Validation / Matching RFC compliant. --- src/messages/messagebuilder.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/messages/messagebuilder.cpp b/src/messages/messagebuilder.cpp index e4d85e6fb..215e89d71 100644 --- a/src/messages/messagebuilder.cpp +++ b/src/messages/messagebuilder.cpp @@ -79,7 +79,7 @@ QString MessageBuilder::matchLink(const QString &string) "$"; static QRegularExpression linkRegex(urlRegExp, QRegularExpression::CaseInsensitiveOption); - + static QRegularExpression httpRegex("\\bhttps?://"); auto match = linkRegex.match(string); if (!match.hasMatch()) { @@ -88,6 +88,10 @@ QString MessageBuilder::matchLink(const QString &string) QString captured = match.captured(); + if (!captured.contains(httpRegex)) { + captured.insert(0, "http://"); + } + return captured; }