Fix funny xss thing (not tested sinve since im in hospital 💀)

This commit is contained in:
Vladimir Barinov 2023-02-10 08:46:29 +02:00 committed by GitHub
parent 0f2a88aa68
commit cf558d57c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View file

@ -428,6 +428,18 @@ function showIncreaseRatingDialog(coinsCount, userUrl, hash) {
};
}
function escapeHtml(text) {
var map = {
'&': '&',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#039;'
};
return text.replace(/[&<>"']/g, function(m) { return map[m]; });
}
$(document).on("scroll", () => {
if($(document).scrollTop() > $(".sidebar").height() + 50) {
$(".floating_sidebar")[0].classList.add("show");

View file

@ -16,6 +16,8 @@ function _bsdnToHumanTime(time) {
}
function _bsdnTpl(name, author) {
name = escapeHtml(name);
return `
<div class="bsdn_contextMenu" style="display: none;">
<span class="bsdn_contextMenuElement bsdn_copyVideoUrl">Copy video link to clipboard</span>