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

Commit 83e14b9

Browse files
author
Gabriel Schulhof
committed
Custom select: Escape weird characters in popup/dialog ID when they become hrefs. Fixes #5893.
(cherry picked from commit f0b2417)
1 parent 3d4108d commit 83e14b9

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
@@ -99,7 +99,10 @@ define( [
9999
placeholder: "",
100100

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

104107
// Create list from select, update state
105108
self.refresh();
@@ -129,9 +132,9 @@ define( [
129132

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

0 commit comments

Comments
 (0)