Skip to content

Commit 5309811

Browse files
committed
Checkboxradio: ensure we are escaping the id before its use in selector
1 parent 81300fe commit 5309811

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ui/checkboxradio.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ var formResetHandler = function() {
3030
form.find( ".ui-checkboxradio" ).checkboxradio( "refresh" );
3131
});
3232
},
33+
escapeId = new RegExp( /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g ),
3334
radioGroup = function( radio ) {
3435
var name = radio.name,
3536
form = radio.form,
@@ -137,7 +138,8 @@ $.widget( "ui.checkboxradio", {
137138
ancestor = this.element.parents().last();
138139

139140
// Look for the label based on the id
140-
labelSelector = "label[for='" + this.element.attr( "id" ) + "']";
141+
labelSelector = "label[for='" +
142+
this.element.attr( "id" ).replace( escapeId, "\\$1" ) + "']";
141143
this.label = ancestor.find( labelSelector );
142144
if ( !this.label.length ) {
143145

@@ -165,7 +167,6 @@ $.widget( "ui.checkboxradio", {
165167
this._setOption( "disabled", this.options.disabled );
166168
this._updateIcon( checked );
167169
this._addClass( "ui-checkboxradio", "ui-helper-hidden-accessible " );
168-
169170
this._addClass( this.label, "ui-checkboxradio-label", "ui-button ui-widget" );
170171

171172
if ( this.type === "radio" ) {

0 commit comments

Comments
 (0)