1
0
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:
Anton Romanov
2015-06-29 15:17:19 -07:00
parent 84d27aa615
commit d3c748c9ae

View File

@@ -109,11 +109,24 @@ Tomahawk.timestamp = function () {
return Math.round(new Date() / 1000); return Math.round(new Date() / 1000);
}; };
Tomahawk.htmlDecode = function (encoded) { Tomahawk.htmlDecode = (function() {
var div = document.createElement('div'); // this prevents any overhead from creating the object each time
div.innerHTML = encoded; var element = document.createElement('textarea');
return div.innerText
}; function decodeHTMLEntities (str) {
if(str && typeof str === 'string') {
str = str.replace(/</g,"&lt;");
str = str.replace(/>/g,"&gt;");
element.innerHTML = str;
str = element.textContent;
element.textContent = '';
}
return str;
}
return decodeHTMLEntities;
})();
Tomahawk.dumpResult = function (result) { Tomahawk.dumpResult = function (result) {
var results = result.results, var results = result.results,