Skip to content

Commit

Permalink
Prevent XSS in GrantsInterface 🛡️
Browse files Browse the repository at this point in the history
  • Loading branch information
wotschofsky committed Nov 28, 2022
1 parent d2aefa9 commit c80d365
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/modules/GrantsInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ export default class GrantsInterface {
const table = document.createElement('table');
table.className = 'consent-manager--table';

for (const category of this.client.config.categories) {
for (const [index, category] of Object.entries(
this.client.config.categories
)) {
const row = document.createElement('tr');
row.className = 'consent-manager--row';

Expand All @@ -126,14 +128,19 @@ export default class GrantsInterface {
const checked = category.required || status ? 'checked' : '';
row.innerHTML =
`<td class="consent-manager--table-toggle-col">` +
` <input id="consent-manager--table-toggle-${category.id}" class="consent-manager--table-toggle" type="checkbox" ${checked} ${disabled} />` +
` <input id="consent-manager--table-toggle-${index}" class="consent-manager--table-toggle" type="checkbox" ${checked} ${disabled} />` +
`</td>` +
`<td class="consent-manager--table-label-col">` +
` <label for="consent-manager--table-toggle-${category.id}">` +
` <span class="consent-manager--table-label">${category.label}</span>` +
` <sub class="consent-manager--table-description">${category.description}</sub>` +
` <label for="consent-manager--table-toggle-${index}">` +
` <span class="consent-manager--table-label"></span>` +
` <sub class="consent-manager--table-description"></sub>` +
` </label>` +
`</td>`;
row.querySelector('consent-manager--table-label').textContent =
category.label;
row.querySelector('consent-manager--table-description').textContent =
category.description;

if (!category.required) {
const checkbox: HTMLInputElement = row.querySelector(
'input[type="checkbox"]'
Expand Down

0 comments on commit c80d365

Please sign in to comment.