@@ -94,11 +94,11 @@ define([
9494 isLocal = function ( anchor ) {
9595 return anchor . hash . length > 1 &&
9696 anchor . href . replace ( rhash , '' ) ===
97- location . href . replace ( rhash , '' )
98- // support: Safari 5.1
99- // Safari 5.1 doesn't encode spaces in window.location
100- // but it does encode spaces from anchors (#8777)
101- . replace ( / \s / g, '%20' ) ;
97+ location . href . replace ( rhash , '' )
98+ // support: Safari 5.1
99+ // Safari 5.1 doesn't encode spaces in window.location
100+ // but it does encode spaces from anchors (#8777)
101+ . replace ( / \s / g, '%20' ) ;
102102 } ;
103103
104104 // Extension for mage.tabs - Move panels in destination element
@@ -126,12 +126,16 @@ define([
126126
127127 if ( ! panel . length ) {
128128 id = $ ( tab ) . attr ( 'aria-controls' ) ;
129- panel = $ ( this . options . destination ) . find ( '#' + CSS . escape ( id ) ) ;
129+ panel = $ ( this . options . destination ) . find ( this . _sanitizeSelector ( '#' + id ) ) ;
130130 }
131131
132132 return panel ;
133133 } ,
134134
135+ _sanitizeSelector : function ( hash ) {
136+ return hash ? hash . replace ( / [ ! " $ % & ' ( ) * + , . \/ : ; < = > ? @ \[ \] \^ ` { | } ~ ] / g, "\\$&" ) : "" ;
137+ } ,
138+
135139 /**
136140 * @private
137141 */
@@ -168,9 +172,8 @@ define([
168172
169173 // inline tab
170174 if ( isLocal ( anchor ) ) {
171- selector = decodeURIComponent ( anchor . hash ) ;
172- panelId = selector . substring ( 1 ) ;
173- panel = that . element . find ( '#' + CSS . escape ( panelId ) ) ;
175+ selector = anchor . hash ;
176+ panel = that . document . find ( that . _sanitizeSelector ( selector ) ) ;
174177 // remote tab
175178 } else {
176179 panelId = tab . attr ( 'aria-controls' ) || $ ( { } ) . uniqueId ( ) [ 0 ] . id ;
0 commit comments