Revert "in Helper.urls2links(), encode HTML entities, find and insert links, partially decoding only the href property of it"

This reverts commit 5340f417e0.
This commit is contained in:
El RIDO 2020-03-06 20:57:15 +01:00
parent 5340f417e0
commit 8a6dcf910a
No known key found for this signature in database
GPG key ID: 0F5C940A6BD81F92
4 changed files with 13 additions and 25 deletions

View file

@ -297,25 +297,10 @@ jQuery.PrivateBin = (function($, RawDeflate) {
*/
me.urls2links = function(html)
{
let reverseEntityMap = {};
for (let entity of ['&', '"', '/', '=']) {
reverseEntityMap[entityMap[entity]] = entity;
}
const entityRegex = new RegExp(Object.keys(reverseEntityMap).join('|'), 'g');
// encode HTML entities, find and insert links, partially decoding only the href property of it
return me.htmlEntities(html)
.replace(
/(((https?|ftp)://[\w?!&.-;#@~%+*-]+(?![\w\s?!&.;#~%-]*>))|((magnet):[\w?&.-;#@~%+*-]+))/ig,
function(encodedUrl) {
let decodedUrl = encodedUrl.replace(
entityRegex, function(entity) {
return reverseEntityMap[entity];
}
);
return '<a href="' + decodedUrl + '" rel="nofollow">' + encodedUrl + '</a>';
}
)
return html.replace(
/(((https?|ftp):\/\/[\w?!=&.\/-;#@~%+*-]+(?![\w\s?!&.\/;#~%"=-]*>))|((magnet):[\w?=&.\/-;#@~%+*-]+))/ig,
'<a href="$1" rel="nofollow">$1</a>'
);
};
/**