diff --git a/frontend/client/res/templates/fields/text/detail.tpl b/frontend/client/res/templates/fields/text/detail.tpl
index f419a58bfb..3ba7ebd6a4 100644
--- a/frontend/client/res/templates/fields/text/detail.tpl
+++ b/frontend/client/res/templates/fields/text/detail.tpl
@@ -1 +1 @@
-{{breaklines value}}
+{{complexText value}}
diff --git a/frontend/client/src/view-helper.js b/frontend/client/src/view-helper.js
index 6308ce13b3..4b202913fc 100644
--- a/frontend/client/src/view-helper.js
+++ b/frontend/client/src/view-helper.js
@@ -22,6 +22,8 @@
(function (Espo, _, Handlebars) {
Espo.ViewHelper = function (options) {
+ this.urlRegex =/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
+
this._registerHandlebarsHelpers();
}
@@ -38,7 +40,6 @@
language: null,
_registerHandlebarsHelpers: function () {
-
var self = this;
Handlebars.registerHelper('img', function (img) {
@@ -131,6 +132,15 @@
text = text.replace(/(\r\n|\n|\r)/gm, '
');
return new Handlebars.SafeString(text);
});
+
+ Handlebars.registerHelper('complexText', function (text) {
+ text = Handlebars.Utils.escapeExpression(text || '');
+ text = text.replace(/(\r\n|\n|\r)/gm, '
');
+ text = text.replace(self.urlRegex, function (url) {
+ return '' + url + '';
+ });
+ return new Handlebars.SafeString(text);
+ });
Handlebars.registerHelper('translateOption', function (name, options) {
var scope = options.hash.scope || null;