Skip to content

Commit

Permalink
cosmetic filtering: support unicode hostnames (#498)
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Mar 23, 2015
1 parent 6724c99 commit 4a07482
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/js/cosmetic-filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/

/* jshint bitwise: false */
/* global µBlock */
/* global punycode, µBlock */

/******************************************************************************/

Expand Down Expand Up @@ -514,6 +514,8 @@ var FilterContainer = function() {
this.selectorCacheAgeMax = 20 * 60 * 1000; // 20 minutes
this.selectorCacheCountMin = 10;
this.selectorCacheTimer = null;
this.reHasUnicode = /[^\x00-\x7F]/;
this.punycode = punycode;
this.reset();
};

Expand Down Expand Up @@ -719,6 +721,13 @@ FilterContainer.prototype.compileHostnameSelector = function(hostname, parsed, o
hostname = hostname.slice(1);
unhide ^= 1;
}

// punycode if needed
if ( this.reHasUnicode.test(hostname) ) {
//console.debug('µBlock.cosmeticFilteringEngine/FilterContainer.compileHostnameSelector> punycoding:', hostname);
hostname = this.punycode.toASCII(hostname);
}

// https://github.com/gorhill/uBlock/issues/188
// If not a real domain as per PSL, assign a synthetic one
var hash;
Expand Down

0 comments on commit 4a07482

Please sign in to comment.