Skip to content

Commit

Permalink
ship this with 0.9.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Mar 15, 2015
1 parent f648727 commit a3abf7a
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/js/1p-filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,30 @@ function allFiltersApplyHandler() {
/******************************************************************************/

var handleImportFilePicker = function() {
// https://github.com/gorhill/uBlock/issues/1004
// Support extraction of filters from ABP backup file
var abpImporter = function(s) {
var reAbpExtractor = /\n\[Subscription\]\n+url=~[\x08-\x7E]+?\[Subscription filters\]([\x08-\x7E]*?)(?:\[Subscription\]|$)/ig;
var matches = reAbpExtractor.exec(s);
// Not an ABP backup file
if ( matches === null ) {
return s;
}
var out = [];
while ( matches !== null ) {
if ( matches.length !== 2 ) {
continue;
}
out.push(matches[1].trim().replace(/\\\[/g, '['));
matches = reAbpExtractor.exec(s);
}
return out.join('\n');
};

var fileReaderOnLoadHandler = function() {
var sanitized = abpImporter(this.result);
var textarea = uDom('#userFilters');
textarea.val([textarea.val(), this.result].join('\n').trim());
textarea.val(textarea.val().trim() + '\n' + sanitized);
userFiltersChanged();
};
var file = this.files[0];
Expand Down Expand Up @@ -150,4 +171,3 @@ uDom.onLoad(function() {
// https://www.youtube.com/watch?v=UNilsLf6eW4

})();

0 comments on commit a3abf7a

Please sign in to comment.