mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
this fixes importing empty ABP custom ruleset
This commit is contained in:
parent
d8a47f1c0b
commit
73ac79feff
2 changed files with 13 additions and 8 deletions
|
|
@ -500,8 +500,8 @@
|
||||||
"description":"Firefox/Fennec-specific: Show Dashboard"
|
"description":"Firefox/Fennec-specific: Show Dashboard"
|
||||||
},
|
},
|
||||||
"showNetworkLogButton":{
|
"showNetworkLogButton":{
|
||||||
"message":"Show Network Request Log",
|
"message":"Show Logger",
|
||||||
"description":"Firefox/Fennec-specific: Show Network Request Log"
|
"description":"Firefox/Fennec-specific: Show Logger"
|
||||||
},
|
},
|
||||||
"fennecMenuItemBlockingOff": {
|
"fennecMenuItemBlockingOff": {
|
||||||
"message": "off",
|
"message": "off",
|
||||||
|
|
|
||||||
|
|
@ -72,19 +72,24 @@ var handleImportFilePicker = function() {
|
||||||
// https://github.com/chrisaljoudi/uBlock/issues/1004
|
// https://github.com/chrisaljoudi/uBlock/issues/1004
|
||||||
// Support extraction of filters from ABP backup file
|
// Support extraction of filters from ABP backup file
|
||||||
var abpImporter = function(s) {
|
var abpImporter = function(s) {
|
||||||
var reAbpExtractor = /\n\[Subscription\]\n+url=~[\x08-\x7E]+?\[Subscription filters\]([\x08-\x7E]*?)(?:\[Subscription\]|$)/ig;
|
var reAbpSubscriptionExtractor = /\n\[Subscription\]\n+url=~[^\n]+([\x08-\x7E]*?)(?:\[Subscription\]|$)/ig;
|
||||||
var matches = reAbpExtractor.exec(s);
|
var reAbpFilterExtractor = /\[Subscription filters\]([\x08-\x7E]*?)(?:\[Subscription\]|$)/i;
|
||||||
|
var matches = reAbpSubscriptionExtractor.exec(s);
|
||||||
// Not an ABP backup file
|
// Not an ABP backup file
|
||||||
if ( matches === null ) {
|
if ( matches === null ) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
//
|
||||||
var out = [];
|
var out = [];
|
||||||
|
var filterMatch;
|
||||||
while ( matches !== null ) {
|
while ( matches !== null ) {
|
||||||
if ( matches.length !== 2 ) {
|
if ( matches.length === 2 ) {
|
||||||
continue;
|
filterMatch = reAbpFilterExtractor.exec(matches[1].trim());
|
||||||
|
if ( filterMatch !== null && filterMatch.length === 2 ) {
|
||||||
|
out.push(filterMatch[1].trim().replace(/\\\[/g, '['));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
out.push(matches[1].trim().replace(/\\\[/g, '['));
|
matches = reAbpSubscriptionExtractor.exec(s);
|
||||||
matches = reAbpExtractor.exec(s);
|
|
||||||
}
|
}
|
||||||
return out.join('\n');
|
return out.join('\n');
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue