From c8071c822aadbb001476870664609abe573e1003 Mon Sep 17 00:00:00 2001 From: gorhill Date: Sun, 30 Apr 2017 07:23:18 -0400 Subject: [PATCH 01/93] fix #2572 --- assets/assets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/assets.json b/assets/assets.json index 91f8bdd24decf..c005fec4a7601 100644 --- a/assets/assets.json +++ b/assets/assets.json @@ -386,7 +386,7 @@ "group": "regions", "off": true, "title": "FRA: EasyList Liste FR", - "lang": "fr", + "lang": "ar fr", "contentURL": "https://easylist-downloads.adblockplus.org/liste_fr.txt", "supportURL": "https://forums.lanik.us/viewforum.php?f=91" }, From 867b675b5c196ac43a563ace6d7eb3a494f2de65 Mon Sep 17 00:00:00 2001 From: gorhill Date: Tue, 2 May 2017 06:19:23 -0400 Subject: [PATCH 02/93] new revision for dev build --- platform/chromium/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/chromium/manifest.json b/platform/chromium/manifest.json index 91fa2cc66a178..fb1168a1fdd92 100644 --- a/platform/chromium/manifest.json +++ b/platform/chromium/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 2, "name": "uBlock Origin", - "version": "1.12.3.1", + "version": "1.12.3.2", "default_locale": "en", "description": "__MSG_extShortDesc__", From 42afd0c3d0c5c0c5552fe6708df3ffe17ed84592 Mon Sep 17 00:00:00 2001 From: gorhill Date: Wed, 3 May 2017 19:43:09 -0400 Subject: [PATCH 03/93] code review: to/from punycode conversion only if needed --- src/js/dynamic-net-filtering.js | 55 ++++++++++++++++++--------------- src/js/hnswitches.js | 44 +++++++++++++------------- 2 files changed, 51 insertions(+), 48 deletions(-) diff --git a/src/js/dynamic-net-filtering.js b/src/js/dynamic-net-filtering.js index 784b9751d513a..f6514af0e6f74 100644 --- a/src/js/dynamic-net-filtering.js +++ b/src/js/dynamic-net-filtering.js @@ -1,7 +1,7 @@ /******************************************************************************* uBlock Origin - a browser extension to block requests. - Copyright (C) 2014-2016 Raymond Hill + Copyright (C) 2014-2017 Raymond Hill This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -444,9 +444,10 @@ Matrix.prototype.desHostnameFromRule = function(rule) { /******************************************************************************/ Matrix.prototype.toString = function() { - var out = []; - var rule, type, val; - var srcHostname, desHostname; + var out = [], + rule, type, val, + srcHostname, desHostname, + toUnicode = punycode.toUnicode; for ( rule in this.rules ) { if ( this.rules.hasOwnProperty(rule) === false ) { continue; @@ -458,12 +459,16 @@ Matrix.prototype.toString = function() { continue; } val = this.evaluateCell(srcHostname, desHostname, type); - if ( val === 0 ) { - continue; + if ( val === 0 ) { continue; } + if ( srcHostname.indexOf('xn--') !== -1 ) { + srcHostname = toUnicode(srcHostname); + } + if ( desHostname.indexOf('xn--') !== -1 ) { + desHostname = toUnicode(desHostname); } out.push( - punycode.toUnicode(srcHostname) + ' ' + - punycode.toUnicode(desHostname) + ' ' + + srcHostname + ' ' + + desHostname + ' ' + type + ' ' + actionToNameMap[val] ); @@ -475,26 +480,18 @@ Matrix.prototype.toString = function() { /******************************************************************************/ Matrix.prototype.fromString = function(text, append) { - var textEnd = text.length; - var lineBeg = 0, lineEnd; - var line, pos, fields; - var srcHostname, desHostname, type, action; + var lineIter = new µBlock.LineIterator(text), + line, pos, fields, + srcHostname, desHostname, type, action, + reNotASCII = /[^\x20-\x7F]/, + toASCII = punycode.toASCII; if ( append !== true ) { this.reset(); } - while ( lineBeg < textEnd ) { - lineEnd = text.indexOf('\n', lineBeg); - if ( lineEnd < 0 ) { - lineEnd = text.indexOf('\r', lineBeg); - if ( lineEnd < 0 ) { - lineEnd = textEnd; - } - } - line = text.slice(lineBeg, lineEnd).trim(); - lineBeg = lineEnd + 1; - + while ( lineIter.eot() === false ) { + line = lineIter.next().trim(); pos = line.indexOf('# '); if ( pos !== -1 ) { line = line.slice(0, pos).trim(); @@ -527,8 +524,16 @@ Matrix.prototype.fromString = function(text, append) { continue; } - srcHostname = punycode.toASCII(fields[0]); - desHostname = punycode.toASCII(fields[1]); + // Performance: avoid punycoding if hostnames are made only of + // ASCII characters. + srcHostname = fields[0]; + if ( reNotASCII.test(srcHostname) ) { + srcHostname = toASCII(srcHostname); + } + desHostname = fields[1]; + if ( reNotASCII.test(desHostname) ) { + desHostname = toASCII(desHostname); + } // https://github.com/chrisaljoudi/uBlock/issues/1082 // Discard rules with invalid hostnames diff --git a/src/js/hnswitches.js b/src/js/hnswitches.js index b929b3f1a930e..b55f8628ced00 100644 --- a/src/js/hnswitches.js +++ b/src/js/hnswitches.js @@ -1,7 +1,7 @@ /******************************************************************************* uBlock Origin - a Chromium browser extension to black/white list requests. - Copyright (C) 2015-2016 Raymond Hill + Copyright (C) 2015-2017 Raymond Hill This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -258,9 +258,10 @@ HnSwitches.prototype.toResultString = function() { /******************************************************************************/ HnSwitches.prototype.toString = function() { - var out = []; - var switchName, val; - var hostname; + var out = [], + switchName, val, + hostname, + toUnicode = punycode.toUnicode; for ( hostname in this.switches ) { if ( this.switches.hasOwnProperty(hostname) === false ) { continue; @@ -270,8 +271,9 @@ HnSwitches.prototype.toString = function() { continue; } val = this.evaluate(switchName, hostname); - if ( val === 0 ) { - continue; + if ( val === 0 ) { continue; } + if ( hostname.indexOf('xn--') !== -1 ) { + hostname = toUnicode(hostname); } out.push(switchName + ': ' + hostname + ' ' + switchStateToNameMap[val]); } @@ -282,25 +284,16 @@ HnSwitches.prototype.toString = function() { /******************************************************************************/ HnSwitches.prototype.fromString = function(text) { - var textEnd = text.length; - var lineBeg = 0, lineEnd; - var line, pos; - var fields; - var switchName, hostname, state; + var lineIter = new µBlock.LineIterator(text), + line, pos, fields, + switchName, hostname, state, + reNotASCII = /[^\x20-\x7F]/, + toASCII = punycode.toASCII; this.reset(); - while ( lineBeg < textEnd ) { - lineEnd = text.indexOf('\n', lineBeg); - if ( lineEnd < 0 ) { - lineEnd = text.indexOf('\r', lineBeg); - if ( lineEnd < 0 ) { - lineEnd = textEnd; - } - } - line = text.slice(lineBeg, lineEnd).trim(); - lineBeg = lineEnd + 1; - + while ( lineIter.eot() === false ) { + line = lineIter.next().trim(); pos = line.indexOf('# '); if ( pos !== -1 ) { line = line.slice(0, pos).trim(); @@ -325,7 +318,12 @@ HnSwitches.prototype.fromString = function(text) { continue; } - hostname = punycode.toASCII(fields[1]); + // Performance: avoid punycoding if hostname is made only of + // ASCII characters. + hostname = fields[1]; + if ( reNotASCII.test(hostname) ) { + hostname = toASCII(hostname); + } state = fields[2]; if ( nameToSwitchStateMap.hasOwnProperty(state) === false ) { From 73def7eab39577d3183b3910c1cc180fa7c2e0ef Mon Sep 17 00:00:00 2001 From: gorhill Date: Wed, 3 May 2017 19:55:41 -0400 Subject: [PATCH 04/93] link warning sign to wiki page about strict-blocking --- src/document-blocked.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/document-blocked.html b/src/document-blocked.html index 25f8d57375cee..ca24ee7b121c3 100644 --- a/src/document-blocked.html +++ b/src/document-blocked.html @@ -125,7 +125,7 @@ -
+