Fix Bug 32934.

This commit is contained in:
Julia Radzhabova 2016-08-09 11:50:51 +03:00
parent 0c14aeb191
commit ccded15130
2 changed files with 30 additions and 28 deletions

View file

@ -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: '<a href="' + ref + '">' + subStr + '</a>'});
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) && (offset<item.end) ||
(offset<=item.start) && (offset+len>item.start));
});
if (!elem)
arr.push({start: offset, end: len+offset, str: '<a href="' + subStr + '" target="_blank" data-can-copy="true">' + subStr + '</a>'});
arr.push({start: offset, end: subStr.length+offset, str: '<a href="' + subStr + '" target="_blank" data-can-copy="true">' + subStr + '</a>'});
return '';
});
@ -259,6 +246,20 @@ define([
arr.push({start: offset, end: len+offset, str: '<a href="' + ref + '" target="_blank" data-can-copy="true">' + subStr + '</a>'});
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) && (offset<item.end) ||
(offset<=item.start) && (offset+len>item.start));
});
if (!elem)
arr.push({start: offset, end: len+offset, str: '<a href="' + ref + '">' + subStr + '</a>'});
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;

View file

@ -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: '<a href="' + ref + '">' + subStr + '</a>'});
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) && (offset<item.end) ||
(offset<=item.start) && (offset+len>item.start));
});
if (!elem)
arr.push({start: offset, end: len+offset, str: '<a href="' + subStr + '" target="_blank" data-can-copy="true">' + subStr + '</a>'});
arr.push({start: offset, end: subStr.length+offset, str: '<a href="' + subStr + '" target="_blank" data-can-copy="true">' + subStr + '</a>'});
return '';
});
@ -1388,6 +1375,20 @@ define([
arr.push({start: offset, end: len+offset, str: '<a href="' + ref + '" target="_blank" data-can-copy="true">' + subStr + '</a>'});
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) && (offset<item.end) ||
(offset<=item.start) && (offset+len>item.start));
});
if (!elem)
arr.push({start: offset, end: len+offset, str: '<a href="' + ref + '">' + subStr + '</a>'});
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;