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

Commit c03a2d4

Browse files
committed
fix handling of IDN for Firefox 55
1 parent 56b4d3d commit c03a2d4

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

js/background.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@ var uBOScope = { // jshint ignore:line
6363
dtpAssetKey: 'disconnect-tracking-protection',
6464
reAuthorityFromURI: /^(?:[^:\/?#]+:)?(\/\/[^\/?#]+)/,
6565
reCommonHostnameFromURL: /^https?:\/\/([0-9a-z_][0-9a-z._-]*[0-9a-z])\//,
66-
reHostFromAuthority: /^(?:[^@]*@)?([0-9a-z._-]+)(?::\d*)?$/i,
66+
reHostFromAuthority: /^(?:[^@]*@)?([^:]+)(?::\d*)?$/,
6767
reHostFromNakedAuthority: /^[0-9a-z._-]+[0-9a-z]$/i,
6868
reIPAddressNaive: /^\d+\.\d+\.\d+\.\d+$|^\[[\da-zA-Z:]+\]$/,
6969
reIPv6FromAuthority: /^(?:[^@]*@)?(\[[0-9a-f:]+\])(?::\d*)?$/i,
70+
reMustNormalizeHostname: /[^0-9a-z._-]/,
7071
settings: {
7172
daysBefore: 30,
7273
heatmapHue: 0,

js/start.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,29 +65,27 @@ uBOScope.getDoY.dayCountLeap = [ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 30
6565

6666
uBOScope.hostnameFromURI = function(uri) {
6767
let matches = this.reCommonHostnameFromURL.exec(uri);
68-
if ( matches ) {
69-
return matches[1];
70-
}
68+
if ( matches !== null ) { return matches[1]; }
7169
matches = this.reAuthorityFromURI.exec(uri);
72-
if ( !matches ) { return ''; }
70+
if ( matches === null ) { return ''; }
7371
const authority = matches[1].slice(2);
7472
// Assume very simple authority (most common case for µBlock)
7573
if ( this.reHostFromNakedAuthority.test(authority) ) {
7674
return authority.toLowerCase();
7775
}
7876
matches = this.reHostFromAuthority.exec(authority);
79-
if ( !matches ) {
77+
if ( matches === null ) {
8078
matches = this.reIPv6FromAuthority.exec(authority);
81-
if ( !matches ) { return ''; }
79+
if ( matches === null ) { return ''; }
8280
}
83-
// http://en.wikipedia.org/wiki/FQDN
84-
// Also:
85-
// - https://github.com/gorhill/uBlock/issues/1559
8681
let hostname = matches[1];
8782
while ( hostname.endsWith('.') ) {
8883
hostname = hostname.slice(0, -1);
8984
}
90-
return hostname.toLowerCase();
85+
if ( this.reMustNormalizeHostname.test(hostname) ) {
86+
hostname = punycode.toASCII(hostname.toLowerCase());
87+
}
88+
return hostname;
9189
};
9290

9391
/******************************************************************************/

0 commit comments

Comments
 (0)