[Pkg-mozext-commits] [requestpolicy] 65/100: do some changes to pull request #506. fixes #304.
David Prévot
taffit at moszumanska.debian.org
Fri Dec 12 22:56:59 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository requestpolicy.
commit d8d0116f9d34e19b9219d392e76c8bb3446e6023
Author: myrdd <myrdd at users.noreply.github.com>
Date: Wed Nov 5 23:33:57 2014 +0100
do some changes to pull request #506. fixes #304.
---
src/content/overlay.js | 38 ++++++++++++++++++++++++-------
src/content/settings/basicprefs.html | 8 ++++---
src/content/settings/basicprefs.js | 19 ++++++++++------
src/defaults/preferences/defaults.js | 2 +-
src/locale/de/requestpolicy.properties | 1 +
src/locale/en-US/requestpolicy.properties | 2 +-
src/locale/eo/requestpolicy.properties | 1 +
src/locale/es-MX/requestpolicy.properties | 1 +
src/locale/eu/requestpolicy.properties | 1 +
src/locale/fr/requestpolicy.properties | 2 +-
src/locale/it/requestpolicy.properties | 1 +
src/locale/ja/requestpolicy.properties | 1 +
src/locale/ko-KR/requestpolicy.properties | 1 +
src/locale/lv-LV/requestpolicy.properties | 1 +
src/locale/nl/requestpolicy.properties | 1 +
src/locale/pt-BR/requestpolicy.properties | 1 +
src/locale/ru-RU/requestpolicy.properties | 1 +
src/locale/sk-SK/requestpolicy.properties | 1 +
src/locale/sv-SE/requestpolicy.properties | 1 +
src/locale/tr/requestpolicy.properties | 1 +
src/locale/uk-UA/requestpolicy.properties | 1 +
src/locale/zh-CN/requestpolicy.properties | 1 +
src/locale/zh-TW/requestpolicy.properties | 1 +
src/modules/DomainUtil.jsm | 8 +++----
src/modules/PolicySubscription.jsm | 23 -------------------
src/modules/RequestResult.jsm | 6 +++++
26 files changed, 77 insertions(+), 48 deletions(-)
diff --git a/src/content/overlay.js b/src/content/overlay.js
index 89ded8e..7efb2ad 100644
--- a/src/content/overlay.js
+++ b/src/content/overlay.js
@@ -662,23 +662,45 @@ requestpolicy.overlay = {
}
},
+ _containsNonBlacklistedRequests : function(requests) {
+ for (let i = 0, len = requests.length; i < len; i++) {
+ if (!requests[i].isOnBlacklist()) {
+ // This request has not benn blocked by the blacklist
+ return true;
+ }
+ }
+ return false;
+ },
+
_indicateBlockedVisibleObjects : function(document) {
if (!this._rpService.prefs.getBoolPref("indicateBlockedObjects")) {
return;
}
+ var indicateBlacklisted = this._rpService.prefs
+ .getBoolPref("indicateBlacklistedObjects");
+
var images = document.getElementsByTagName("img");
var rejectedRequests = this._rpService._requestProcessor.
_rejectedRequests.getOriginUri(document.location);
- var blockedUris = {};
+ var blockedUrisToIndicate = {};
for (var destBase in rejectedRequests) {
for (var destIdent in rejectedRequests[destBase]) {
for (var destUri in rejectedRequests[destBase][destIdent]) {
- var shouldPlacehold = this._rpService.prefs.getBoolPref("indicateBlacklistedObjects");
- var results = rejectedRequests[destBase][destIdent][destUri];
- for(var i=0; i < results.length && !shouldPlacehold; i++)
- shouldPlacehold = results[i].isDefaultPolicyUsed(); // if a request is blocked not by the default policy it's by a blacklist
- if(shouldPlacehold)
- blockedUris[destUri] = true;
+ // case 1: indicateBlacklisted == true
+ // ==> indicate the object has been blocked
+ //
+ // case 2: indicateBlacklisted == false
+ // case 2a: all requests have been blocked because of a blacklist
+ // ==> do *not* indicate
+ //
+ // case 2b: at least one of the blocked (identical) requests has been
+ // blocked by a rule *other than* the blacklist
+ // ==> *do* indicate
+ let requests = rejectedRequests[destBase][destIdent][destUri];
+ if (indicateBlacklisted ||
+ this._containsNonBlacklistedRequests(requests)) {
+ blockedUrisToIndicate[destUri] = true;
+ }
}
}
}
@@ -701,7 +723,7 @@ requestpolicy.overlay = {
for (var i = 0; i < images.length; i++) {
var img = images[i];
// Note: we're no longer checking img.requestpolicyBlocked here.
- if (!img.requestpolicyIdentified && img.src in blockedUris) {
+ if (!img.requestpolicyIdentified && img.src in blockedUrisToIndicate) {
img.requestpolicyIdentified = true;
img.style.border = "solid 1px #fcc";
img.style.backgroundRepeat = "no-repeat";
diff --git a/src/content/settings/basicprefs.html b/src/content/settings/basicprefs.html
index 8447629..a68c940 100644
--- a/src/content/settings/basicprefs.html
+++ b/src/content/settings/basicprefs.html
@@ -45,10 +45,12 @@
<span data-string="indicateBlockedImages"></span>
</label>
</div>
- <div>
+ <div id="indicateBlockedImages-details">
<label>
- <input type="checkbox" id="pref-indicateBlacklistedObjects"/>
- <span data-string="indicateBlacklistedImages"></span>
+
+ <input type="checkbox"
+ id="pref-dontIndicateBlacklistedObjects"/>
+ <span data-string="dontIndicateBlacklisted"></span>
</label>
</div>
<div>
diff --git a/src/content/settings/basicprefs.js b/src/content/settings/basicprefs.js
index 930bf8b..c730a13 100644
--- a/src/content/settings/basicprefs.js
+++ b/src/content/settings/basicprefs.js
@@ -3,7 +3,7 @@ PAGE_STRINGS = [
'advanced',
'webPages',
'indicateBlockedImages',
- 'indicateBlacklistedImages',
+ 'dontIndicateBlacklisted',
'autoReload',
'menu',
'allowAddingNonTemporaryRulesInPBM'
@@ -17,11 +17,12 @@ var prefsChangedObserver = null;
function updateDisplay() {
- document.getElementById('pref-indicateBlockedObjects').checked =
- rpService.prefs.getBoolPref('indicateBlockedObjects');
+ var indicate = rpService.prefs.getBoolPref('indicateBlockedObjects');
+ document.getElementById('pref-indicateBlockedObjects').checked = indicate;
+ document.getElementById('indicateBlockedImages-details').hidden = !indicate;
- document.getElementById('pref-indicateBlacklistedObjects').checked =
- rpService.prefs.getBoolPref('indicateBlacklistedObjects');
+ document.getElementById('pref-dontIndicateBlacklistedObjects').checked =
+ !rpService.prefs.getBoolPref('indicateBlacklistedObjects');
document.getElementById('pref-autoReload').checked =
rpService.prefs.getBoolPref('autoReload');
@@ -45,13 +46,15 @@ function onload() {
function (event) {
rpService.prefs.setBoolPref('indicateBlockedObjects', event.target.checked);
rpService._prefService.savePrefFile(null);
+ updateDisplay();
}
);
- document.getElementById('pref-indicateBlacklistedObjects').addEventListener('change',
+ document.getElementById('pref-dontIndicateBlacklistedObjects').addEventListener('change',
function (event) {
- rpService.prefs.setBoolPref('indicateBlacklistedObjects', event.target.checked);
+ rpService.prefs.setBoolPref('indicateBlacklistedObjects', !event.target.checked);
rpService._prefService.savePrefFile(null);
+ updateDisplay();
}
);
@@ -59,6 +62,7 @@ function onload() {
function(event) {
rpService.prefs.setBoolPref('autoReload', event.target.checked);
rpService._prefService.savePrefFile(null);
+ updateDisplay();
}
);
@@ -66,6 +70,7 @@ function onload() {
function (event) {
rpService.prefs.setBoolPref('privateBrowsingPermanentWhitelisting', event.target.checked);
rpService._prefService.savePrefFile(null);
+ updateDisplay();
}
);
diff --git a/src/defaults/preferences/defaults.js b/src/defaults/preferences/defaults.js
index 9db0bcf..c218b7d 100644
--- a/src/defaults/preferences/defaults.js
+++ b/src/defaults/preferences/defaults.js
@@ -13,7 +13,7 @@ pref("extensions.requestpolicy.defaultPolicy.allowSameDomain", true);
pref("extensions.requestpolicy.welcomeWindowShown", false);
pref("extensions.requestpolicy.indicateBlockedObjects", true);
-pref("extensions.requestpolicy.indicateBlacklistedObjects", true);
+pref("extensions.requestpolicy.indicateBlacklistedObjects", false);
pref("extensions.requestpolicy.startWithAllowAllEnabled", false);
pref("extensions.requestpolicy.privateBrowsingPermanentWhitelisting", false);
diff --git a/src/locale/de/requestpolicy.properties b/src/locale/de/requestpolicy.properties
index d0ec038..44f673a 100644
--- a/src/locale/de/requestpolicy.properties
+++ b/src/locale/de/requestpolicy.properties
@@ -39,6 +39,7 @@ help=Help
basic=Basic
advanced=Erweitert
indicateBlockedImages=Blockierte Grafiken durch Platzhalter ersetzen
+dontIndicateBlacklisted=Exception: images blocked by a blacklist
autoReload=Aktuelle Seite beim Ändern der Liste erlaubter Anfragen neu laden
webPages=Webseiten
menu=Menu
diff --git a/src/locale/en-US/requestpolicy.properties b/src/locale/en-US/requestpolicy.properties
index f7ef5d9..63a66dc 100644
--- a/src/locale/en-US/requestpolicy.properties
+++ b/src/locale/en-US/requestpolicy.properties
@@ -39,7 +39,7 @@ help=Help
basic=Basic
advanced=Advanced
indicateBlockedImages=Indicate blocked images
-indicateBlacklistedImages=Indicate blocked by blacklist images
+dontIndicateBlacklisted=Exception: images blocked by a blacklist
autoReload=Reload current page when whitelist is changed
webPages=Web Pages
menu=Menu
diff --git a/src/locale/eo/requestpolicy.properties b/src/locale/eo/requestpolicy.properties
index 10809e3..9c22a06 100644
--- a/src/locale/eo/requestpolicy.properties
+++ b/src/locale/eo/requestpolicy.properties
@@ -39,6 +39,7 @@ help=Help
basic=Basic
advanced=Spertulaj
indicateBlockedImages=Indiki blokitajn bildojn
+dontIndicateBlacklisted=Exception: images blocked by a blacklist
autoReload=Reŝargi la montratan paĝon ĉe ŝanĝo de permesoj.
webPages=Retpaĝoj
menu=Menu
diff --git a/src/locale/es-MX/requestpolicy.properties b/src/locale/es-MX/requestpolicy.properties
index cbb88ab..881ccdb 100644
--- a/src/locale/es-MX/requestpolicy.properties
+++ b/src/locale/es-MX/requestpolicy.properties
@@ -39,6 +39,7 @@ help=Help
basic=Basic
advanced=Avanzado
indicateBlockedImages=Indicar imágenes bloqueadas
+dontIndicateBlacklisted=Exception: images blocked by a blacklist
autoReload=Recargar la pagina actual cuando cambie la lista de sitios permitidos
webPages=Paginas web
menu=Menu
diff --git a/src/locale/eu/requestpolicy.properties b/src/locale/eu/requestpolicy.properties
index 88dd0c2..ebf6a59 100644
--- a/src/locale/eu/requestpolicy.properties
+++ b/src/locale/eu/requestpolicy.properties
@@ -39,6 +39,7 @@ help=Help
basic=Basic
advanced=Aurreratua
indicateBlockedImages=Adierazi blokeatutako irudiak
+dontIndicateBlacklisted=Exception: images blocked by a blacklist
autoReload=Berritu uneko orria zerrenda-zuria aldatzen denean
webPages=Web orriak
menu=Menu
diff --git a/src/locale/fr/requestpolicy.properties b/src/locale/fr/requestpolicy.properties
index bb78935..b7e322c 100644
--- a/src/locale/fr/requestpolicy.properties
+++ b/src/locale/fr/requestpolicy.properties
@@ -39,7 +39,7 @@ help=Help
basic=Basic
advanced=Avancé
indicateBlockedImages=Indiquer les images bloquées
-indicateBlacklistedImages=Indiquer les images bloquées par blacklist
+dontIndicateBlacklisted=Exception: images blocked by a blacklist
autoReload=Actualiser la page en cours lorsque liste blanche est modifiée
webPages=Pages Web
menu=Menu
diff --git a/src/locale/it/requestpolicy.properties b/src/locale/it/requestpolicy.properties
index 743f641..a4df47d 100644
--- a/src/locale/it/requestpolicy.properties
+++ b/src/locale/it/requestpolicy.properties
@@ -39,6 +39,7 @@ help=Aiuto
basic=Di base
advanced=Avanzate
indicateBlockedImages=Indica le immagini bloccate
+dontIndicateBlacklisted=Exception: images blocked by a blacklist
autoReload=Ricarica la pagina corrente quando cambia la Lista Bianca
webPages=Pagine Web
menu=Menu
diff --git a/src/locale/ja/requestpolicy.properties b/src/locale/ja/requestpolicy.properties
index 4638ac1..f24b73a 100644
--- a/src/locale/ja/requestpolicy.properties
+++ b/src/locale/ja/requestpolicy.properties
@@ -39,6 +39,7 @@ help=Help
basic=Basic
advanced=上級者向け設定
indicateBlockedImages=ブロックされたことを示す画像を表示する
+dontIndicateBlacklisted=Exception: images blocked by a blacklist
autoReload=Reload current page when whitelist is changed
webPages=Webページ
menu=Menu
diff --git a/src/locale/ko-KR/requestpolicy.properties b/src/locale/ko-KR/requestpolicy.properties
index af0d0a6..d562887 100644
--- a/src/locale/ko-KR/requestpolicy.properties
+++ b/src/locale/ko-KR/requestpolicy.properties
@@ -39,6 +39,7 @@ help=Help
basic=Basic
advanced=Advanced
indicateBlockedImages=거부된 사이트 표시
+dontIndicateBlacklisted=Exception: images blocked by a blacklist
autoReload=Reload current page when whitelist is changed
webPages=Web Pages
menu=Menu
diff --git a/src/locale/lv-LV/requestpolicy.properties b/src/locale/lv-LV/requestpolicy.properties
index 9858056..7d0dccb 100644
--- a/src/locale/lv-LV/requestpolicy.properties
+++ b/src/locale/lv-LV/requestpolicy.properties
@@ -39,6 +39,7 @@ help=Help
basic=Basic
advanced=Papildus
indicateBlockedImages=Atzīmēt bloķetus attēlus
+dontIndicateBlacklisted=Exception: images blocked by a blacklist
autoReload=Atjaunināt pašreizējo lapu, kad izmaina balto sarakstu
webPages=Web Pages
menu=Menu
diff --git a/src/locale/nl/requestpolicy.properties b/src/locale/nl/requestpolicy.properties
index e3eaccc..65f33a7 100644
--- a/src/locale/nl/requestpolicy.properties
+++ b/src/locale/nl/requestpolicy.properties
@@ -39,6 +39,7 @@ help=Help
basic=Basic
advanced=Geavanceerd
indicateBlockedImages=Geblokkeerde afbeeldingen aanduiden
+dontIndicateBlacklisted=Exception: images blocked by a blacklist
autoReload=Huidige pagina opnieuw laden wanneer witte lijst wijzigt
webPages=Webpagina’s
menu=Menu
diff --git a/src/locale/pt-BR/requestpolicy.properties b/src/locale/pt-BR/requestpolicy.properties
index 7a39e71..7482132 100644
--- a/src/locale/pt-BR/requestpolicy.properties
+++ b/src/locale/pt-BR/requestpolicy.properties
@@ -39,6 +39,7 @@ help=Help
basic=Basic
advanced=Avançado
indicateBlockedImages=Indicar imagens bloqueadas
+dontIndicateBlacklisted=Exception: images blocked by a blacklist
autoReload=Recarregar a página logo após modificar a lista de permissões
webPages=Exibição da página
menu=Menu
diff --git a/src/locale/ru-RU/requestpolicy.properties b/src/locale/ru-RU/requestpolicy.properties
index de0e648..0397670 100644
--- a/src/locale/ru-RU/requestpolicy.properties
+++ b/src/locale/ru-RU/requestpolicy.properties
@@ -39,6 +39,7 @@ help=Help
basic=Basic
advanced=Дополнительно
indicateBlockedImages=Помечать заблокированные изображения
+dontIndicateBlacklisted=Exception: images blocked by a blacklist
autoReload=Перегружать текущую страницу при изменении белого списка
webPages=Веб-страницы
menu=Menu
diff --git a/src/locale/sk-SK/requestpolicy.properties b/src/locale/sk-SK/requestpolicy.properties
index d07047e..3285961 100644
--- a/src/locale/sk-SK/requestpolicy.properties
+++ b/src/locale/sk-SK/requestpolicy.properties
@@ -39,6 +39,7 @@ help=Help
basic=Basic
advanced=Pokročilé
indicateBlockedImages=Uviesť blokované obrázky
+dontIndicateBlacklisted=Exception: images blocked by a blacklist
autoReload=Znovu načítať aktuálnu stránku pri zmene whitelist
webPages=Webové stránky
menu=Menu
diff --git a/src/locale/sv-SE/requestpolicy.properties b/src/locale/sv-SE/requestpolicy.properties
index 69ee150..effe927 100644
--- a/src/locale/sv-SE/requestpolicy.properties
+++ b/src/locale/sv-SE/requestpolicy.properties
@@ -39,6 +39,7 @@ help=Help
basic=Basic
advanced=Avancerat
indicateBlockedImages=Indikera blockerade bilder
+dontIndicateBlacklisted=Exception: images blocked by a blacklist
autoReload=Ladda om nuvarande sida när vitlistan ändras
webPages=Webbsidor
menu=Menu
diff --git a/src/locale/tr/requestpolicy.properties b/src/locale/tr/requestpolicy.properties
index 6d44fa3..b9517ab 100644
--- a/src/locale/tr/requestpolicy.properties
+++ b/src/locale/tr/requestpolicy.properties
@@ -39,6 +39,7 @@ help=Help
basic=Basic
advanced=Gelişmiş
indicateBlockedImages=Bloklanan resimi işaretle
+dontIndicateBlacklisted=Exception: images blocked by a blacklist
autoReload=Beyaz liste değiştiğinde sayfayı yenile
webPages=Web sayfaları
menu=Menu
diff --git a/src/locale/uk-UA/requestpolicy.properties b/src/locale/uk-UA/requestpolicy.properties
index c516221..81bb5b2 100644
--- a/src/locale/uk-UA/requestpolicy.properties
+++ b/src/locale/uk-UA/requestpolicy.properties
@@ -39,6 +39,7 @@ help=Help
basic=Basic
advanced=Додатково
indicateBlockedImages=Indicate blocked images
+dontIndicateBlacklisted=Exception: images blocked by a blacklist
autoReload=Reload current page when whitelist is changed
webPages=Веб-сторінки
menu=Menu
diff --git a/src/locale/zh-CN/requestpolicy.properties b/src/locale/zh-CN/requestpolicy.properties
index 96dbb59..33064d1 100644
--- a/src/locale/zh-CN/requestpolicy.properties
+++ b/src/locale/zh-CN/requestpolicy.properties
@@ -39,6 +39,7 @@ help=帮助
basic=基础
advanced=高级
indicateBlockedImages=标示已阻止的图像
+dontIndicateBlacklisted=Exception: images blocked by a blacklist
autoReload=白名单更改后重新载入当前页面
webPages=网页
menu=菜单
diff --git a/src/locale/zh-TW/requestpolicy.properties b/src/locale/zh-TW/requestpolicy.properties
index 2d46954..dbf448b 100644
--- a/src/locale/zh-TW/requestpolicy.properties
+++ b/src/locale/zh-TW/requestpolicy.properties
@@ -39,6 +39,7 @@ help=Help
basic=Basic
advanced=進階
indicateBlockedImages=Indicate blocked images
+dontIndicateBlacklisted=Exception: images blocked by a blacklist
autoReload=更改白名單後重新載入目前頁面
webPages=網頁
menu=Menu
diff --git a/src/modules/DomainUtil.jsm b/src/modules/DomainUtil.jsm
index dbecd95..a35cb19 100644
--- a/src/modules/DomainUtil.jsm
+++ b/src/modules/DomainUtil.jsm
@@ -297,9 +297,9 @@ DomainUtil.destinationIsSubdomainOfOrigin = function(destinationHost,
*
* @param {String}
* refreshString The original content of a refresh header or meta tag.
- * @return {Array} First element is the delay in seconds, second element is the
- * url to refresh to. The url may be an empty string if the current url
- * should be refreshed.
+ * @return {Object} The delay in seconds and the url to refresh to.
+ * The url may be an empty string if the current url should be
+ * refreshed.
* @throws Generic
* exception if the refreshString has an invalid format, including if
* the seconds can't be parsed as a float.
@@ -322,7 +322,7 @@ DomainUtil.parseRefresh = function(refreshString) {
url = url.substring(1, url.length - 1);
}
}
- return [delay, url];
+ return {delay: delay, destURI: url};
}
/**
diff --git a/src/modules/PolicySubscription.jsm b/src/modules/PolicySubscription.jsm
deleted file mode 100644
index 7bb8aec..0000000
--- a/src/modules/PolicySubscription.jsm
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * ***** BEGIN LICENSE BLOCK *****
- *
- * RequestPolicy - A Firefox extension for control over cross-site requests.
- * Copyright (c) 2011 Justin Samuel
- *
- * 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 the Free Software
- * Foundation, either version 3 of the License, or (at your option) any later
- * version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * ***** END LICENSE BLOCK *****
- */
-
-var EXPORTED_SYMBOLS = ["PolicySubscription"];
diff --git a/src/modules/RequestResult.jsm b/src/modules/RequestResult.jsm
index 09196f2..b90fef1 100644
--- a/src/modules/RequestResult.jsm
+++ b/src/modules/RequestResult.jsm
@@ -90,5 +90,11 @@ RequestResult.prototype = {
return (this.resultReason == REQUEST_REASON_DEFAULT_POLICY ||
this.resultReason == REQUEST_REASON_DEFAULT_POLICY_INCONSISTENT_RULES ||
this.resultReason == REQUEST_REASON_DEFAULT_SAME_DOMAIN);
+ },
+
+ isOnBlacklist: function() {
+ // TODO: implement a real blacklist. currently, if a request is blocked
+ // *not* by the default policy it's by a blacklist
+ return this.isAllowed ? false : !this.isDefaultPolicyUsed();
}
};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git
More information about the Pkg-mozext-commits
mailing list