From d63592b11ee4d0ac61eb644bea0642b1983a0b28 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sat, 16 Feb 2019 19:25:15 -0500 Subject: [PATCH] Remove obsolete code to translate `|blob:` filters into CSP filters These filters are to be considered obsolete since they can't be matched against network requests in the webRequest API. They were probably meant to work when ABP was pre-webext, which means they are quite probably obsolete and there is no longer a point for uBO to conveniently translate them into CSP directives. --- src/js/static-net-filtering.js | 97 ---------------------------------- 1 file changed, 97 deletions(-) diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index d36b7e9dc..c3b65950e 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -1593,96 +1593,6 @@ FilterParser.prototype.parseOptions = function(s) { } }; -/******************************************************************************/ - -// https://github.com/gorhill/uBlock/issues/1943#issuecomment-243188946 -// Convert websocket-related filter where possible to a format which -// can be handled using CSP injection. - -FilterParser.prototype.translate = function() { - var dataTypeBit = this.bitFromType('data'); - - if ( this.cantWebsocket && this.reWebsocketAny.test(this.f) ) { - this.f = '*'; - this.types = dataTypeBit; - this.dataType = 'csp'; - this.dataStr = "connect-src https: http:"; - // https://bugs.chromium.org/p/chromium/issues/detail?id=669086 - // TODO: remove when most users are beyond Chromium v56 - if ( - vAPI.webextFlavor.soup.has('chromium') && - vAPI.webextFlavor.major < 57 - ) { - this.dataStr += '; frame-src *'; - } - return; - } - - // Broad |data:-based filters. - if ( this.f === 'data:' ) { - switch ( this.types ) { - case 0: - this.f = '*'; - this.types = dataTypeBit; - this.dataType = 'csp'; - this.dataStr = "default-src 'self' * blob: 'unsafe-inline' 'unsafe-eval'"; - break; - case this.bitFromType('script'): - this.f = '*'; - this.types = dataTypeBit; - this.dataType = 'csp'; - this.dataStr = "script-src 'self' * blob: 'unsafe-inline' 'unsafe-eval'"; - break; - case this.bitFromType('sub_frame'): - this.f = '*'; - this.types = dataTypeBit; - this.dataType = 'csp'; - this.dataStr = "frame-src 'self' * blob:"; - break; - case this.bitFromType('script') | this.bitFromType('sub_frame'): - this.f = '*'; - this.types = dataTypeBit; - this.dataType = 'csp'; - this.dataStr = "frame-src 'self' * blob:; script-src 'self' * blob: 'unsafe-inline' 'unsafe-eval';"; - break; - default: - break; - } - } - - // Broad |blob:-based filters. - if ( this.f === 'blob:' ) { - switch ( this.types ) { - case 0: - this.f = '*'; - this.types = dataTypeBit; - this.dataType = 'csp'; - this.dataStr = "default-src 'self' * data: 'unsafe-inline' 'unsafe-eval'"; - break; - case this.bitFromType('script'): - this.f = '*'; - this.types = dataTypeBit; - this.dataType = 'csp'; - this.dataStr = "script-src 'self' * data: 'unsafe-inline' 'unsafe-eval'"; - break; - case this.bitFromType('sub_frame'): - this.f = '*'; - this.types = dataTypeBit; - this.dataType = 'csp'; - this.dataStr = "frame-src 'self' * data:"; - break; - case this.bitFromType('script') | this.bitFromType('sub_frame'): - this.f = '*'; - this.types = dataTypeBit; - this.dataType = 'csp'; - this.dataStr = "frame-src 'self' * data:; script-src 'self' * data: 'unsafe-inline' 'unsafe-eval';"; - break; - default: - break; - } - } -}; - /******************************************************************************* anchor: bit vector @@ -1851,13 +1761,6 @@ FilterParser.prototype.parse = function(raw) { this.f = this.reHasUppercase.test(s) ? s.toLowerCase() : s; - // Convenience: - // Convert special broad filters for non-webRequest aware types into - // `csp` filters wherever possible. - if ( this.anchor & 0x2 && this.party === 0 ) { - this.translate(); - } - return this; };