Skip to content

Commit e391f04

Browse files
author
Peter Eckersley
committed
Merge pull request EFForg#276 from EFForg/better-obs-whitelisting
Better obs whitelisting The less ugly but also less async version
2 parents f310ca9 + 5d0dd0b commit e391f04

File tree

6 files changed

+1138
-1031
lines changed

6 files changed

+1138
-1031
lines changed

src/chrome/content/code/HTTPSRules.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,9 @@ const RuleWriter = {
241241
return rv;
242242
},
243243

244-
read: function(file, rule_store, ruleset_id) {
244+
read: function(file) {
245245
if (!file.exists())
246246
return null;
247-
if ((rule_store.targets == null) && (rule_store.targets != {}))
248-
this.log(WARN, "TARGETS IS NULL");
249247
var data = "";
250248
var fstream = CC["@mozilla.org/network/file-input-stream;1"]
251249
.createInstance(CI.nsIFileInputStream);
@@ -262,6 +260,28 @@ const RuleWriter = {
262260

263261
sstream.close();
264262
fstream.close();
263+
return data;
264+
},
265+
266+
write: function(file, data) {
267+
//if (!file.exists())
268+
// return null;
269+
this.log(DBUG, "Opening " + file.path + " for writing");
270+
var fstream = CC["@mozilla.org/network/file-output-stream;1"]
271+
.createInstance(CI.nsIFileOutputStream);
272+
fstream.init(file, -1, -1, 0);
273+
274+
var retval = fstream.write(data, data.length);
275+
this.log(DBUG, "Got retval " + retval);
276+
fstream.close();
277+
return data;
278+
},
279+
280+
rulesetFromFile: function(file, rule_store, ruleset_id) {
281+
if ((rule_store.targets == null) && (rule_store.targets != {}))
282+
this.log(WARN, "TARGETS IS NULL");
283+
var data = this.read(file);
284+
if (!data) return null;
265285
return this.readFromString(data, rule_store, ruleset_id);
266286
},
267287

0 commit comments

Comments
 (0)