Skip to content

Commit 8748658

Browse files
committed
Tabs: Don't decode URLs if they're not UTF-8. Fixes #9518 - Tabs: URLs encoded in anything other than UTF-8 will throw an error.
1 parent 0a1ab40 commit 8748658

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

ui/jquery.ui.tabs.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,24 @@ $.widget( "ui.tabs", {
3636
var rhash = /#.*$/;
3737

3838
return function( anchor ) {
39+
var anchorUrl, locationUrl;
3940

4041
// support: IE7
4142
// IE7 doesn't normalize the href property when set via script (#9317)
4243
anchor = anchor.cloneNode( false );
4344

44-
return anchor.hash.length > 1 &&
45-
decodeURIComponent( anchor.href.replace( rhash, "" ) ) ===
46-
decodeURIComponent( location.href.replace( rhash, "" ) );
45+
anchorUrl = anchor.href.replace( rhash, "" );
46+
locationUrl = location.href.replace( rhash, "" );
47+
48+
// decoding may throw an error if the URL isn't UTF-8 (#9518)
49+
try {
50+
anchorUrl = decodeURIComponent( anchorUrl );
51+
} catch ( error ) {}
52+
try {
53+
locationUrl = decodeURIComponent( locationUrl );
54+
} catch ( error ) {}
55+
56+
return anchor.hash.length > 1 && anchorUrl === locationUrl;
4757
};
4858
})(),
4959

0 commit comments

Comments
 (0)