Skip to content
This repository has been archived by the owner on Nov 15, 2017. It is now read-only.

Commit

Permalink
this fixes #330
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Jun 6, 2014
1 parent 5adac68 commit 0d332a4
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 9 deletions.
4 changes: 4 additions & 0 deletions _locales/de/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,10 @@
"message": "Eine Regel pro Zeile. Eine Regel kann ein einfacher Hostname sein oder ein Adblock Plus-kompatibler Filter. Zeilen mit vorangestelltem ‘#’ werden ignoriert.",
"description": "English: One rule per line. A rule can be a plain hostname, or an Adblock Plus-compatible filter. Lines prefixed with ‘#’ will be ignored."
},
"ubiquitousAllowFormatHint" : {
"message": "Eine Regel pro Zeile. Eine Regel kann ein einfacher Hostname sein oder ein Adblock Plus-kompatibler Filter. Zeilen mit vorangestelltem ‘#’ werden ignoriert.",
"description": "English: One rule per line. A rule can be a plain hostname, or an Adblock Plus-compatible exception filter. Lines prefixed with ‘#’ will be ignored."
},
"ubiquitousImport" : {
"message": "Importieren und anfügen",
"description": "English: Import and append"
Expand Down
4 changes: 4 additions & 0 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,10 @@
"message": "One rule per line. A rule can be a plain hostname, or an Adblock Plus-compatible filter. Lines prefixed with ‘#’ will be ignored.",
"description": "English: One rule per line. A rule can be a plain hostname, or an Adblock Plus-compatible filter. Lines prefixed with ‘#’ will be ignored."
},
"ubiquitousAllowFormatHint" : {
"message": "One rule per line. A rule can be a plain hostname, or an Adblock Plus-compatible exception filter. Lines prefixed with ‘#’ will be ignored.",
"description": "English: One rule per line. A rule can be a plain hostname, or an Adblock Plus-compatible exception filter. Lines prefixed with ‘#’ will be ignored."
},
"ubiquitousImport" : {
"message": "Import and append",
"description": "English: Import and append"
Expand Down
4 changes: 4 additions & 0 deletions _locales/fr/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,10 @@
"message": "Une règle par ligne. Une règle peut être un simple nom d'hôte, ou encore un filtre respectant la syntaxe des filtres Adblock Plus. Les lignes débutant par ‘#’ seront ignorées.",
"description": "English: One rule per line. A rule can be a plain hostname, or an Adblock Plus-compatible filter. Lines prefixed with ‘#’ will be ignored."
},
"ubiquitousAllowFormatHint" : {
"message": "Une règle par ligne. Une règle peut être un simple nom d'hôte, ou encore un filtre respectant la syntaxe des filtres d'exception Adblock Plus. Les lignes débutant par ‘#’ seront ignorées.",
"description": "English: One rule per line. A rule can be a plain hostname, or an Adblock Plus-compatible exception filter. Lines prefixed with ‘#’ will be ignored."
},
"ubiquitousImport" : {
"message": "Importer",
"description": "English: Import and append"
Expand Down
4 changes: 4 additions & 0 deletions _locales/ru/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,10 @@
"message": "Одно правило на строку. Правилом может быть обычное имя сайти, или Adblock Plus-совместимый фильтр. Линии начинающиеся с ‘#’ будут пропущены.",
"description": "English: One rule per line. A rule can be a plain hostname, or an Adblock Plus-compatible filter. Lines prefixed with ‘#’ will be ignored."
},
"ubiquitousAllowFormatHint" : {
"message": "Одно правило на строку. Правилом может быть обычное имя сайти, или Adblock Plus-совместимый фильтр. Линии начинающиеся с ‘#’ будут пропущены.",
"description": "English: One rule per line. A rule can be a plain hostname, or an Adblock Plus-compatible exception filter. Lines prefixed with ‘#’ will be ignored."
},
"ubiquitousImport" : {
"message": "Импортировать и добавить",
"description": "English: Import and append"
Expand Down
8 changes: 5 additions & 3 deletions _locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@
"description": "To help the user understand the purpose of strict blocking"
},
"settingsAutoCreateScopePrompt1": {
"message": "Auto create temporary",
"message": "自动添加临时",
"description": "English: Auto create temporary"
},
Expand Down Expand Up @@ -369,9 +368,8 @@
"description": "..."
},
"settingsDeleteBlockedLocalStoragePrompt" : {
"message": "Delete <a href='https://en.wikipedia.org/wiki/Web_storage'>local storage</a> content set by blocked hostnames",
"message": "删除被屏蔽站点名的<a href='https://zh.wikipedia.org/wiki/%E7%BD%91%E9%A1%B5%E5%AD%98%E5%82%A8'>本地网页存储</a>内容集。",
"description": "..."
"description": "English: Delete <a href='https://en.wikipedia.org/wiki/Web_storage'>local storage</a> content set by blocked hostnames"
},
"settingsDeleteBlockedLocalStorageHelp" : {
"message": "TODO",
Expand Down Expand Up @@ -487,6 +485,10 @@
"message": "每行一条规则。一条规则可以是一个平凡的站点名或者是一条Adblock Plus的兼容过滤规则。以“#”开头的行将被忽略。",
"description": "English: One rule per line. A rule can be a plain hostname, or an Adblock Plus-compatible filter. Lines prefixed with &lsquo;#&rsquo; will be ignored."
},
"ubiquitousAllowFormatHint" : {
"message": "每行一条规则。一条规则可以是一个平凡的站点名或者是一条Adblock Plus的兼容过滤规则。以“#”开头的行将被忽略。",
"description": "English: One rule per line. A rule can be a plain hostname, or an Adblock Plus-compatible exception filter. Lines prefixed with &lsquo;#&rsquo; will be ignored."
},
"ubiquitousImport" : {
"message": "导入并附加规则",
"description": "English: Import and append"
Expand Down
24 changes: 19 additions & 5 deletions js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,10 @@ HTTPSB.loadUbiquitousWhitelists = function() {

HTTPSB.mergeUbiquitousWhitelist = function(details) {
var ubiquitousWhitelist = this.ubiquitousWhitelist;
var reAdblockFilter = /^[^a-z0-9:]|[^a-z0-9]$|[^a-z0-9_:.-]/;
var reAdblockHideFilter = /#@#/;
var reAdblockNetFilter = /^@@/;
var abpNetFilters = this.userSettings.parseAllABPFilters ? this.abpFilters : null;
var abpHideFilters = this.userSettings.parseAllABPHideFilters ? this.abpHideFilters : null;
var raw = details.content.toLowerCase();
var rawEnd = raw.length;
var lineBeg = 0;
Expand All @@ -183,6 +186,21 @@ HTTPSB.mergeUbiquitousWhitelist = function(details) {
}
line = raw.slice(lineBeg, lineEnd).trim();
lineBeg = lineEnd + 1;

if ( reAdblockHideFilter.test(line) ) {
if ( abpHideFilters !== null ) {
abpHideFilters.add(line);
}
continue;
}

if ( reAdblockNetFilter.test(line) ) {
if ( abpNetFilters !== null ) {
abpNetFilters.add(line);
}
continue;
}

pos = line.indexOf('#');
if ( pos >= 0 ) {
line = line.slice(0, pos);
Expand All @@ -191,10 +209,6 @@ HTTPSB.mergeUbiquitousWhitelist = function(details) {
if ( line === '' ) {
continue;
}
// Ignore whatever appears to be an Adblock filters
if ( reAdblockFilter.test(line) ) {
continue;
}
ubiquitousWhitelist.add(line);
}
};
Expand Down
2 changes: 1 addition & 1 deletion ubiquitous-rules.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ <h2 id="userUbiquitousBlacklistedHostsPrompt" data-i18n="userUbiquitousBlacklist

<h2 data-i18n="userUbiquitousWhitelistHeader"></h2>
<div>
<p data-i18n="ubiquitousFormatHint"></p>
<p data-i18n="ubiquitousAllowFormatHint"></p>
<p><button id="importUserWhitelistFromFile" data-i18n="ubiquitousImport"></button> &emsp; <button id="exportUserWhitelistToFile" data-i18n="ubiquitousExport"></button></p>
<textarea class="userUbiquitousHosts" id="userUbiquitousWhitelistedHosts"></textarea>
<p><button id="userUbiquitousWhitelistApply" disabled="true" data-i18n="ubiquitousApplyChanges"></button></p>
Expand Down

0 comments on commit 0d332a4

Please sign in to comment.