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

Commit f0b2417

Browse files
author
Gabriel Schulhof
committed
Custom select: Escape weird characters in popup/dialog ID when they become hrefs. Fixes #5893.
1 parent 541f963 commit f0b2417

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

js/widgets/forms/select.custom.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ define( [
9898
placeholder: "",
9999

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

103106
// Create list from select, update state
104107
self.refresh();
@@ -128,9 +131,9 @@ define( [
128131

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

0 commit comments

Comments
 (0)