Skip to content

Commit ed89b50

Browse files
author
ehynds
committed
move the logic that sets the button text into its own method so that it can be overridden, and use text() instead of html() by default to prevent XSS attacks. fixes #229
1 parent 35b98fb commit ed89b50

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/jquery.multiselect.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,17 @@
228228
}
229229
}
230230

231-
this.buttonlabel.html(value);
231+
this._setButtonValue(value);
232232

233233
return value;
234234
},
235235

236+
// this exists as a separate method so that the developer
237+
// can easily override it.
238+
_setButtonValue: function(value) {
239+
this.buttonlabel.text(value);
240+
},
241+
236242
// binds events
237243
_bindEvents: function() {
238244
var self = this;

tests/unit/options.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,13 @@
120120
});
121121

122122
test("selectedList - encoding", function() {
123+
expect(1);
124+
123125
el = $('<select><option value="A&amp;E">A&amp;E</option></select>')
124126
.appendTo("body")
125127
.multiselect({ selectedList: 1 });
126128

127-
equals(button().text(), 'A&E');
128-
equals(button().find("span").last().html(), 'A&amp;E');
129+
equals(button().text(), 'A&amp;E');
129130
el.multiselect("destroy").remove();
130131
});
131132

0 commit comments

Comments
 (0)