From ccded15130ff1a292460318bb1d7804eaccf72ef Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 9 Aug 2016 11:50:51 +0300 Subject: [PATCH] Fix Bug 32934. --- apps/common/main/lib/view/Chat.js | 29 ++++++++++++++------------- apps/common/main/lib/view/Comments.js | 29 ++++++++++++++------------- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/apps/common/main/lib/view/Chat.js b/apps/common/main/lib/view/Chat.js index 536a1ca77..75bf4fafe 100644 --- a/apps/common/main/lib/view/Chat.js +++ b/apps/common/main/lib/view/Chat.js @@ -227,22 +227,9 @@ define([ _pickLink: function(message) { var arr = [], offset, len; - message.replace(Common.Utils.emailStrongRe, function(subStr) { - var ref = (! /((^mailto:)\/\/)/i.test(subStr) ) ? ('mailto:' + subStr) : subStr; - offset = arguments[arguments.length-2]; - arr.push({start: offset, end: subStr.length+offset, str: '' + subStr + ''}); - return ''; - }); - message.replace(Common.Utils.ipStrongRe, function(subStr) { offset = arguments[arguments.length-2]; - len = subStr.length; - var elem = _.find(arr, function(item){ - return ( (offset>=item.start) && (offsetitem.start)); - }); - if (!elem) - arr.push({start: offset, end: len+offset, str: '' + subStr + ''}); + arr.push({start: offset, end: subStr.length+offset, str: '' + subStr + ''}); return ''; }); @@ -259,6 +246,20 @@ define([ arr.push({start: offset, end: len+offset, str: '' + subStr + ''}); return ''; }); + + message.replace(Common.Utils.emailStrongRe, function(subStr) { + var ref = (! /((^mailto:)\/\/)/i.test(subStr) ) ? ('mailto:' + subStr) : subStr; + offset = arguments[arguments.length-2]; + len = subStr.length; + var elem = _.find(arr, function(item){ + return ( (offset>=item.start) && (offsetitem.start)); + }); + if (!elem) + arr.push({start: offset, end: len+offset, str: '' + subStr + ''}); + return ''; + }); + arr = _.sortBy(arr, function(item){ return item.start; }); var str_res = (arr.length>0) ? ( message.substring(0, arr[0].start) + arr[0].str) : message; diff --git a/apps/common/main/lib/view/Comments.js b/apps/common/main/lib/view/Comments.js index a6f0fce84..8deac95d0 100644 --- a/apps/common/main/lib/view/Comments.js +++ b/apps/common/main/lib/view/Comments.js @@ -1356,22 +1356,9 @@ define([ var arr = [], offset, len; message = Common.Utils.String.htmlEncode(message); - message.replace(Common.Utils.emailStrongRe, function(subStr) { - var ref = (! /((^mailto:)\/\/)/i.test(subStr) ) ? ('mailto:' + subStr) : subStr; - offset = arguments[arguments.length-2]; - arr.push({start: offset, end: subStr.length+offset, str: '' + subStr + ''}); - return ''; - }); - message.replace(Common.Utils.ipStrongRe, function(subStr) { offset = arguments[arguments.length-2]; - len = subStr.length; - var elem = _.find(arr, function(item){ - return ( (offset>=item.start) && (offsetitem.start)); - }); - if (!elem) - arr.push({start: offset, end: len+offset, str: '' + subStr + ''}); + arr.push({start: offset, end: subStr.length+offset, str: '' + subStr + ''}); return ''; }); @@ -1388,6 +1375,20 @@ define([ arr.push({start: offset, end: len+offset, str: '' + subStr + ''}); return ''; }); + + message.replace(Common.Utils.emailStrongRe, function(subStr) { + var ref = (! /((^mailto:)\/\/)/i.test(subStr) ) ? ('mailto:' + subStr) : subStr; + offset = arguments[arguments.length-2]; + len = subStr.length; + var elem = _.find(arr, function(item){ + return ( (offset>=item.start) && (offsetitem.start)); + }); + if (!elem) + arr.push({start: offset, end: len+offset, str: '' + subStr + ''}); + return ''; + }); + arr = _.sortBy(arr, function(item){ return item.start; }); var str_res = (arr.length>0) ? ( message.substring(0, arr[0].start) + arr[0].str) : message;