1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-18 17:02:27 +02:00

Prevent duplicate inline-script entries in the logger

Related discussion:
- https://www.reddit.com/r/uBlockOrigin/comments/c4340z/filter_problem/ervpjd8/
This commit is contained in:
Raymond Hill 2019-06-24 11:40:14 -04:00
parent 5caa369229
commit 8e7384ba84
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -202,7 +202,8 @@ vAPI.SafeAnimationFrame.prototype = {
// are properly reported in the logger. // are properly reported in the logger.
{ {
const events = new Set(); const newEvents = new Set();
const allEvents = new Set();
let timer; let timer;
const send = function() { const send = function() {
@ -212,14 +213,17 @@ vAPI.SafeAnimationFrame.prototype = {
what: 'securityPolicyViolation', what: 'securityPolicyViolation',
type: 'net', type: 'net',
docURL: document.location.href, docURL: document.location.href,
violations: Array.from(events), violations: Array.from(newEvents),
}, },
response => { response => {
if ( response === true ) { return; } if ( response === true ) { return; }
stop(); stop();
} }
); );
events.clear(); for ( const event of newEvents ) {
allEvents.add(event);
}
newEvents.clear();
}; };
const sendAsync = function() { const sendAsync = function() {
@ -233,16 +237,19 @@ vAPI.SafeAnimationFrame.prototype = {
const listener = function(ev) { const listener = function(ev) {
if ( ev.isTrusted !== true ) { return; } if ( ev.isTrusted !== true ) { return; }
if ( ev.disposition !== 'enforce' ) { return; } if ( ev.disposition !== 'enforce' ) { return; }
events.add(JSON.stringify({ const json = JSON.stringify({
url: ev.blockedURL || ev.blockedURI, url: ev.blockedURL || ev.blockedURI,
policy: ev.originalPolicy, policy: ev.originalPolicy,
directive: ev.effectiveDirective || ev.violatedDirective, directive: ev.effectiveDirective || ev.violatedDirective,
})); });
if ( allEvents.has(json) ) { return; }
newEvents.add(json);
sendAsync(); sendAsync();
}; };
const stop = function() { const stop = function() {
events.clear(); newEvents.clear();
allEvents.clear();
if ( timer !== undefined ) { if ( timer !== undefined ) {
self.cancelIdleCallback(timer); self.cancelIdleCallback(timer);
timer = undefined; timer = undefined;