Skip to content

Commit

Permalink
fix: Fixed loading named settings (#50)
Browse files Browse the repository at this point in the history
Refs: #51
  • Loading branch information
pbezliapovich authored Jun 28, 2024
1 parent f3f46ea commit 23a96ed
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions app/src/main/resources/js/custom-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@ SbbCustomSelect.prototype.selectMultipleValues = function(values) {
this.handleChange();
};

// Using code like:
// this.selectElement.innerHTML = "<option>" + document.createTextNode(selectedCheckbox.parentElement.textContent).textContent + "</option>"
// results in XSS vulnerability. The code below solves this issue.
SbbCustomSelect.prototype.setSelectedOptionValue = function(optionText) {
const optionElement = document.createElement("option");
optionElement.textContent = optionText;
this.selectElement.innerHTML = '';
this.selectElement.appendChild(optionElement);
};

SbbCustomSelect.prototype.handleChange = function(event) {
if (this.mutiselect) {
this.setSelectedOptionValue(this.getSelectedText().join(", "));
Expand Down Expand Up @@ -161,14 +171,4 @@ SbbCustomSelect.prototype.handleChange = function(event) {
}
this.checkboxContainer.style.display = "none";
}

// Using code like:
// this.selectElement.innerHTML = "<option>" + document.createTextNode(selectedCheckbox.parentElement.textContent).textContent + "</option>"
// results in XSS vulnerability. The code below solves this issue.
SbbCustomSelect.prototype.setSelectedOptionValue = function(optionText) {
const optionElement = document.createElement("option");
optionElement.textContent = optionText;
this.selectElement.innerHTML = '';
this.selectElement.appendChild(optionElement);
};
}

0 comments on commit 23a96ed

Please sign in to comment.