mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 13:47:26 +02:00
Use xss safe version
This commit is contained in:
@@ -109,11 +109,24 @@ Tomahawk.timestamp = function () {
|
||||
return Math.round(new Date() / 1000);
|
||||
};
|
||||
|
||||
Tomahawk.htmlDecode = function (encoded) {
|
||||
var div = document.createElement('div');
|
||||
div.innerHTML = encoded;
|
||||
return div.innerText
|
||||
};
|
||||
Tomahawk.htmlDecode = (function() {
|
||||
// this prevents any overhead from creating the object each time
|
||||
var element = document.createElement('textarea');
|
||||
|
||||
function decodeHTMLEntities (str) {
|
||||
if(str && typeof str === 'string') {
|
||||
str = str.replace(/</g,"<");
|
||||
str = str.replace(/>/g,">");
|
||||
element.innerHTML = str;
|
||||
str = element.textContent;
|
||||
element.textContent = '';
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
return decodeHTMLEntities;
|
||||
})();
|
||||
|
||||
Tomahawk.dumpResult = function (result) {
|
||||
var results = result.results,
|
||||
|
Reference in New Issue
Block a user