mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2025-05-02 06:26:16 -04:00
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:
parent
5340f417e0
commit
8a6dcf910a
4 changed files with 13 additions and 25 deletions
|
@ -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>'
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue