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);
|
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,"<");
|
||||||
|
str = str.replace(/>/g,">");
|
||||||
|
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,
|
||||||
|
Reference in New Issue
Block a user