From e1936a49e7f382d7f9ab1402a3eb48cd3cf73401 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 27 Jun 2018 12:54:06 +0200 Subject: [PATCH] Fix "parsing" of email-addresses in comments and chat messages \\b matches any non-word character, including \@ and \- In order to not detect urls in the middle of email-addresses, we need to check for white space characters and beginning of the message instead. Signed-off-by: Joas Schilling --- core/js/public/comments.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/js/public/comments.js b/core/js/public/comments.js index ac0bf8e0ab..318d527b13 100644 --- a/core/js/public/comments.js +++ b/core/js/public/comments.js @@ -21,7 +21,7 @@ * The downside: anything not ascii is excluded. Not sure how common it is in areas using different * alphabets… the upside: fake domains with similar looking characters won't be formatted as links */ - urlRegex: /(\b(https?:\/\/|([-A-Z0-9+_])*\.([-A-Z])+)[-A-Z0-9+&@#\/%?=~_|!:,.;()]*[-A-Z0-9+&@#\/%=~_|()])/ig, + urlRegex: /((\s|^)(https?:\/\/|([-A-Z0-9+_])*\.([-A-Z])+)[-A-Z0-9+&@#\/%?=~_|!:,.;()]*[-A-Z0-9+&@#\/%=~_|()])/ig, protocolRegex: /^https:\/\//, plainToRich: function(content) { @@ -39,7 +39,7 @@ return content.replace(this.urlRegex, function(url) { var hasProtocol = (url.indexOf('https://') !== -1) || (url.indexOf('http://') !== -1); if(!hasProtocol) { - url = 'https://' + url; + url = 'https://' + url.trim(); } var linkText = url.replace(self.protocolRegex, '');