diff --git a/platform/firefox/vapi-background-ext.js b/platform/firefox/vapi-background-ext.js index 79787cc99..92c2d95c9 100644 --- a/platform/firefox/vapi-background-ext.js +++ b/platform/firefox/vapi-background-ext.js @@ -314,7 +314,7 @@ vAPI.Net = class extends vAPI.Net { const { addresses } = record; if ( Array.isArray(addresses) === false ) { return; } if ( addresses.length === 0 ) { return; } - return addresses[0]; + return addresses.join('\n'); } suspendOneRequest(details) { diff --git a/src/js/benchmarks.js b/src/js/benchmarks.js index e97490e60..79cc89922 100644 --- a/src/js/benchmarks.js +++ b/src/js/benchmarks.js @@ -174,6 +174,7 @@ export async function benchmarkStaticNetFiltering(options = {}) { for ( let i = 0; i < requests.length; i++ ) { const request = requests[i]; fctxt.setURL(request.url); + fctxt.setIPAddress('93.184.215.14\n2606:2800:21f:cb07:6820:80da:af6b:8b2c'); fctxt.setDocOriginFromURL(request.frameUrl); fctxt.setType(request.cpt); sfne.redirectURL = undefined; diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index afbd9f01e..5ae59f062 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -2993,16 +2993,14 @@ class FilterIPAddress { if ( ipaddr === '' ) { return false; } const details = filterRefs[filterData[idata+1]]; switch ( details.$type || this.TYPE_UNKNOWN ) { - case this.TYPE_EQUAL: - return ipaddr === details.pattern; case this.TYPE_LAN: return this.isLAN(ipaddr); case this.TYPE_LOOPBACK: return this.isLoopback(ipaddr); + case this.TYPE_EQUAL: case this.TYPE_STARTSWITH: - return ipaddr.startsWith(details.$pattern); case this.TYPE_RE: - return details.$pattern.test(ipaddr) + return details.$pattern.test(ipaddr); default: break; } @@ -3013,12 +3011,13 @@ class FilterIPAddress { details.$type = this.TYPE_LOOPBACK; } else if ( pattern.startsWith('/') && pattern.endsWith('/') ) { details.$type = this.TYPE_RE; - details.$pattern = new RegExp(pattern.slice(1, -1)); + details.$pattern = new RegExp(pattern.slice(1, -1), 'm'); } else if ( pattern.endsWith('*') ) { details.$type = this.TYPE_STARTSWITH; - details.$pattern = pattern.slice(0, -1); + details.$pattern = new RegExp(`^${restrFromPlainPattern(pattern.slice(0, -1))}`, 'm'); } else { details.$type = this.TYPE_EQUAL; + details.$pattern = new RegExp(`^${restrFromPlainPattern(pattern)}$`, 'm'); } return this.match(idata); } @@ -3049,13 +3048,11 @@ class FilterIPAddress { if ( ipaddr.startsWith('::ffff:') === false ) { return false; } return this.reIPv6IPv4lan.test(ipaddr); } - if ( ipaddr.includes(':') ) { - if ( c0 === 0x36 /* 6 */ ) { - return ipaddr.startsWith('64:ff9b:'); - } - if ( c0 === 0x66 /* f */ ) { - return this.reIPv6local.test(ipaddr); - } + if ( c0 === 0x36 /* 6 */ ) { + return ipaddr.startsWith('64:ff9b:'); + } + if ( c0 === 0x66 /* f */ ) { + return this.reIPv6local.test(ipaddr); } return false; } @@ -5641,6 +5638,12 @@ StaticNetFilteringEngine.prototype.test = function(details) { } } } + const urlskips = this.matchAndFetchModifiers(fctxt, 'urlskip'); + if ( urlskips ) { + for ( const urlskip of urlskips ) { + out.push(`modified: ${urlskip.logData().raw}`); + } + } return out.join('\n'); }