From afaee6ec9c5382db49dd2d4e1fd7da34e9aadf7c Mon Sep 17 00:00:00 2001 From: Lajamerr Mittesdine Date: Tue, 5 Jun 2018 09:29:59 -0400 Subject: [PATCH] Intermediate updates of RFC Compliant URL Matching Just some small changes. Fixing IP range exclusion and fixing ftp link so it doesn't include http:// when you copy it. --- src/messages/messagebuilder.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/messages/messagebuilder.cpp b/src/messages/messagebuilder.cpp index 215e89d71..b9120178a 100644 --- a/src/messages/messagebuilder.cpp +++ b/src/messages/messagebuilder.cpp @@ -50,11 +50,6 @@ QString MessageBuilder::matchLink(const QString &string) // user:pass authentication "(?:\\S+(?::\\S*)?@)?" "(?:" - // IP address exclusion - // private & local networks - "(?!(?:10|127)(?:\\.\\d{1,3}){3})" - "(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})" - "(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})" // IP address dotted notation octets // excludes loopback network 0.0.0.0 // excludes reserved space >= 224.0.0.0 @@ -80,6 +75,7 @@ QString MessageBuilder::matchLink(const QString &string) static QRegularExpression linkRegex(urlRegExp, QRegularExpression::CaseInsensitiveOption); static QRegularExpression httpRegex("\\bhttps?://"); + static QRegularExpression ftpRegex("\\bftp?://"); auto match = linkRegex.match(string); if (!match.hasMatch()) { @@ -88,8 +84,10 @@ QString MessageBuilder::matchLink(const QString &string) QString captured = match.captured(); - if (!captured.contains(httpRegex)) { - captured.insert(0, "http://"); + if (!captured.contains(httpRegex)) { + if (!captured.contains(ftpRegex)) { + captured.insert(0, "http://"); + } } return captured;