Skip to content

Commit d5189bf

Browse files
committed
Merge pull request #592 from enkarito/master
Escape html characters - optgroup label - prevent XSS attacks.
2 parents b34d1d3 + 6a8e0b7 commit d5189bf

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/jquery.multiselect.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,13 @@
152152

153153
// has this optgroup been added already?
154154
if($.inArray(optLabel, optgroups) === -1) {
155-
html += '<li class="ui-multiselect-optgroup-label ' + parent.className + '"><a href="#">' + optLabel + '</a></li>';
155+
var optLabelEscaped = optLabel.replace(/&/g, '&amp;')
156+
.replace(/>/g, '&gt;')
157+
.replace(/</g, '&lt;')
158+
.replace(/'/g, '&#39;')
159+
.replace(/\//g, '&#x2F;')
160+
.replace(/"/g, '&quot;');
161+
html += '<li class="ui-multiselect-optgroup-label ' + parent.className + '"><a href="#">' + optLabelEscaped + '</a></li>';
156162
optgroups.push(optLabel);
157163
}
158164
}

0 commit comments

Comments
 (0)