Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting rid of some silly XSS #7

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions app/html/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ <h2>Custom /top Embed Color</h2>
$('.serverName').text(data.guild.name)
$('.serverMembers').text(commafy(data.guild.members || "?") + " member" + (data.guild.members == 1 ? "" : "s"))
$('.serverIcon').attr('src', data.guild.icon || "/assets/avatar.png")
$('#otherServers').append(data.ownedServers.map(x => `<option value="${x.id}">${x.name}</option>`))
$('#otherServers').append(data.ownedServers.map(x => $("<option></option>").val(x.id).text(x.name)))

// fill in inputs with current values
$('input[db], select[db]').each(function() {
Expand Down Expand Up @@ -978,7 +978,7 @@ <h2>Custom /top Embed Color</h2>
})

presets.forEach(x => {
$('#curvePresets').append(`<option value="${x.name}">${x.name}</option>`)
$('#curvePresets').append($(`<option></option>`).val(x.name).text(x.name))
})

let foundPreset = presets.find(x => x.name != data.guild.name && JSON.stringify([x.curve, x.round, x.bestRange]) == JSON.stringify([db.curve, db.rounding, [db.gain.min, db.gain.max]])) || presets[0]
Expand Down Expand Up @@ -1053,7 +1053,7 @@ <h2>Custom /top Embed Color</h2>
if (!extra) columns = columns.filter(x => !x.extra)

element.empty();
element.append(columns.map(x => `<div col="${x.id}"><p><b>${x.name}</b></p></div>`))
element.append(columns.map(x => `<div col="${x.id}"><p><b>${x.name}</b></p></div>`)) // WARNING: be weary of XSS (hacking) because of this line if you for some reason let users add columns

levels.forEach(lvl => {

Expand Down Expand Up @@ -1191,7 +1191,7 @@ <h2>Custom /top Embed Color</h2>

// role selectors
data.roles.forEach(x => {
let roleOption = $(`<option value="${x.id}">${x.name}</option>`)
let roleOption = $("<option></option>").val(x.id).text(x.name)
roleOption.css("color", x.color == "#000000" ? "var(--defaultrolecol)" : x.color)

if (!x.managed) appendRoleSelect('#rewardRoleSelect', roleOption, x, true, rewards.some(r => r.id == x.id))
Expand Down Expand Up @@ -1285,7 +1285,7 @@ <h2>Custom /top Embed Color</h2>
else $(`#roleMultiplierSelect option[value=${boost.id}]`).prop('hidden', true)

$('#roleMultipliers div[col="boost"]').append(`<p class="roleMultiplierAmount numberinput" roleID="${boost.id}" min="0" max="100" decimals="4" default="1" tabindex="-1" contenteditable>${+boost.boost}x</p>`)
$('#roleMultipliers div[col="role"]').append(`<p class="longname" style="color: ${foundRole.color == "#000000" ? "var(--defaultrolecol)" : foundRole.color}">${foundRole.name}</p>`)
$('#roleMultipliers div[col="role"]').append($(`<p class="longname" style="color: ${foundRole.color == "#000000" ? "var(--defaultrolecol)" : foundRole.color}"></p>`).text(foundRole.name)) // sneaky one
$('#roleMultipliers div[col="delete"]').append(`<p class="deleteRow deleteRoleMultiplier" tabindex="0" roleID="${boost.id}">🗑️</p>`)
})
$('#roleMultiplierCount').html(roleMultipliers.length)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"name": "polaris",
"version": "1.0.0",
"main": "index.js",
"main": "polaris.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
Expand Down