From b35aa272d5166af31a495150f037860630239a12 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Tue, 12 Dec 2017 16:47:10 -0500 Subject: [PATCH] better translate NoScript whitelist directives into uMatrix rules --- src/js/user-rules.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/js/user-rules.js b/src/js/user-rules.js index af3df6b..d0c65f2 100644 --- a/src/js/user-rules.js +++ b/src/js/user-rules.js @@ -1,7 +1,7 @@ /******************************************************************************* - µMatrix - a Chromium browser extension to block requests. - Copyright (C) 2014 Raymond Hill + uMatrix - a Chromium browser extension to block requests. + Copyright (C) 2014-2017 Raymond Hill 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 @@ -145,7 +145,7 @@ var fromNoScript = function(content) { ) { return; } - var out = {}; + var out = new Set(); var reBad = /[a-z]+:\w*$/; var reURL = /[a-z]+:\/\/([0-9a-z.-]+)/; var directives = noscript.whitelist.split(/\s+/); @@ -163,9 +163,11 @@ var fromNoScript = function(content) { if ( matches !== null ) { directive = matches[1]; } - out['* ' + directive + ' script allow'] = true; + out.add('* ' + directive + ' * allow'); + out.add('* ' + directive + ' script allow'); + out.add('* ' + directive + ' frame allow'); } - return Object.keys(out).join('\n'); + return Array.from(out).join('\n'); }; /******************************************************************************/