Commit ccded151 authored by Julia Radzhabova's avatar Julia Radzhabova

Fix Bug 32934.

parent 0c14aeb1
......@@ -227,14 +227,15 @@ define([
_pickLink: function(message) {
var arr = [], offset, len;
message.replace(Common.Utils.emailStrongRe, function(subStr) {
var ref = (! /((^mailto:)\/\/)/i.test(subStr) ) ? ('mailto:' + subStr) : subStr;
message.replace(Common.Utils.ipStrongRe, function(subStr) {
offset = arguments[arguments.length-2];
arr.push({start: offset, end: subStr.length+offset, str: '<a href="' + ref + '">' + subStr + '</a>'});
arr.push({start: offset, end: subStr.length+offset, str: '<a href="' + subStr + '" target="_blank" data-can-copy="true">' + subStr + '</a>'});
return '';
});
message.replace(Common.Utils.ipStrongRe, function(subStr) {
if (message.length<1000 || message.search(/\S{255,}/)<0)
message.replace(Common.Utils.hostnameStrongRe, function(subStr) {
var ref = (! /(((^https?)|(^ftp)):\/\/)/i.test(subStr) ) ? ('http://' + subStr) : subStr;
offset = arguments[arguments.length-2];
len = subStr.length;
var elem = _.find(arr, function(item){
......@@ -242,13 +243,12 @@ define([
(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: len+offset, str: '<a href="' + ref + '" target="_blank" data-can-copy="true">' + subStr + '</a>'});
return '';
});
if (message.length<1000 || message.search(/\S{255,}/)<0)
message.replace(Common.Utils.hostnameStrongRe, function(subStr) {
var ref = (! /(((^https?)|(^ftp)):\/\/)/i.test(subStr) ) ? ('http://' + subStr) : subStr;
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){
......@@ -256,9 +256,10 @@ define([
(offset<=item.start) && (offset+len>item.start));
});
if (!elem)
arr.push({start: offset, end: len+offset, str: '<a href="' + ref + '" target="_blank" data-can-copy="true">' + subStr + '</a>'});
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;
......
......@@ -1356,14 +1356,15 @@ 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;
message.replace(Common.Utils.ipStrongRe, function(subStr) {
offset = arguments[arguments.length-2];
arr.push({start: offset, end: subStr.length+offset, str: '<a href="' + ref + '">' + subStr + '</a>'});
arr.push({start: offset, end: subStr.length+offset, str: '<a href="' + subStr + '" target="_blank" data-can-copy="true">' + subStr + '</a>'});
return '';
});
message.replace(Common.Utils.ipStrongRe, function(subStr) {
if (message.length<1000 || message.search(/\S{255,}/)<0)
message.replace(Common.Utils.hostnameStrongRe, function(subStr) {
var ref = (! /(((^https?)|(^ftp)):\/\/)/i.test(subStr) ) ? ('http://' + subStr) : subStr;
offset = arguments[arguments.length-2];
len = subStr.length;
var elem = _.find(arr, function(item){
......@@ -1371,13 +1372,12 @@ define([
(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: len+offset, str: '<a href="' + ref + '" target="_blank" data-can-copy="true">' + subStr + '</a>'});
return '';
});
if (message.length<1000 || message.search(/\S{255,}/)<0)
message.replace(Common.Utils.hostnameStrongRe, function(subStr) {
var ref = (! /(((^https?)|(^ftp)):\/\/)/i.test(subStr) ) ? ('http://' + subStr) : subStr;
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){
......@@ -1385,9 +1385,10 @@ define([
(offset<=item.start) && (offset+len>item.start));
});
if (!elem)
arr.push({start: offset, end: len+offset, str: '<a href="' + ref + '" target="_blank" data-can-copy="true">' + subStr + '</a>'});
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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment