Use angular function to linkify text.
Fixes bugs with HTML escaping in text
This commit is contained in:
parent
69200c7854
commit
1615f3016b
|
@ -254,7 +254,7 @@ $ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out rel
|
|||
</td>
|
||||
<td class="prefix"><span ng-repeat="part in bufferline.prefix" ng-class="{{ part.classes }}">{{ part.text }}</span></td>
|
||||
<td class="message">
|
||||
<span ng-repeat="part in bufferline.content" class="text" ng-class="{{ part.classes }}" ng-bind-html="part.text"></span>
|
||||
<span ng-repeat="part in bufferline.content" class="text" ng-class="{{ part.classes }}" ng-bind-html="part.text|linky:'_blank'"></span>
|
||||
|
||||
<div ng-repeat="metadata in bufferline.metadata">
|
||||
<div ng-show="metadata.visible">
|
||||
|
|
|
@ -80,19 +80,6 @@ plugins.service('plugins', ['userPlugins', '$sce', function(userPlugins, $sce) {
|
|||
}
|
||||
}
|
||||
|
||||
/* Replace all URLs with hyperlinks */
|
||||
|
||||
var urlRegexp = RegExp(/(http|ftp|https):\/\/[\w-]+(\.[\w-]+)+([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/g);
|
||||
for(k in message.content) {
|
||||
var text = message.content[k].text;
|
||||
var url = text.match(urlRegexp);
|
||||
for(i in url) {
|
||||
var u = url[i];
|
||||
text = text.replace(u, '<a target="_blank" href="' + u + '">' + u + '</a>');
|
||||
}
|
||||
message.content[k].text = $sce.trustAsHtml(text);
|
||||
}
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue