Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
Custom select: Escape weird characters in popup/dialog ID when they b…
Browse files Browse the repository at this point in the history
…ecome hrefs. Fixes #5893.
  • Loading branch information
Gabriel Schulhof committed Apr 17, 2013
1 parent 541f963 commit f0b2417
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions js/widgets/forms/select.custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ define( [
placeholder: "",

build: function() {
var self = this;
var self = this,
escapeId = function( id ) {
return id.replace( /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g, "\\$1" );
}

// Create list from select, update state
self.refresh();
Expand Down Expand Up @@ -128,9 +131,9 @@ define( [

self._decideFormat();
if ( self.menuType === "overlay" ) {
self.button.attr( "href", "#" + self.popupID ).attr( "data-" + ( $.mobile.ns || "" ) + "rel", "popup" );
self.button.attr( "href", "#" + escapeId( self.popupID ) ).attr( "data-" + ( $.mobile.ns || "" ) + "rel", "popup" );
} else {
self.button.attr( "href", "#" + self.dialogID ).attr( "data-" + ( $.mobile.ns || "" ) + "rel", "dialog" );
self.button.attr( "href", "#" + escapeId( self.dialogID ) ).attr( "data-" + ( $.mobile.ns || "" ) + "rel", "dialog" );
}
self.isOpen = true;
// Do not prevent default, so the navigation may have a chance to actually open the chosen format
Expand Down

0 comments on commit f0b2417

Please sign in to comment.