Sanitize track name (#312)

to prevent code in GPX getting executed like this:
<name>&lt;img src="xyz" onerror="alert('script executed')"></name>
This commit is contained in:
Norbert Renner 2020-07-14 09:27:57 +02:00
parent dd4eb6c406
commit 9500481df0
3 changed files with 11 additions and 11 deletions

View file

@ -97,5 +97,14 @@ BR.Util = {
}
return true;
},
// this method must only be used to sanitize for textContent.
// do NOT use it to sanitize any attribute,
// see https://web.archive.org/web/20121208091505/http://benv.ca/2012/10/4/you-are-probably-misusing-DOM-text-methods/
sanitizeHTMLContent: function(str) {
var temp = document.createElement('div');
temp.textContent = str;
return temp.innerHTML;
}
};