1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-05 18:32:30 +01:00

Do not assume wildcards fall on label boundaries

Related commit:
- fe0b7a0e0f

Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/572#issuecomment-492223980
This commit is contained in:
Raymond Hill 2019-05-14 09:29:45 -04:00
parent 93f80eedfa
commit a14dcecf8f
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -305,11 +305,14 @@ RedirectEngine.prototype.compileRuleFromStaticFilter = function(line) {
// https://github.com/uBlockOrigin/uBlock-issues/issues/572
// Extract best possible hostname.
let deshn = des;
const pos = deshn.lastIndexOf('*');
let pos = deshn.lastIndexOf('*');
if ( pos !== -1 ) {
deshn = deshn.slice(pos + 1);
if ( deshn.charCodeAt(0) === 0x2E /* '.' */ ) {
deshn = deshn.replace(/\.+/, '');
pos = deshn.indexOf('.');
if ( pos !== -1 ) {
deshn = deshn.slice(pos + 1);
} else {
deshn = '';
}
}
@ -334,7 +337,7 @@ RedirectEngine.prototype.compileRuleFromStaticFilter = function(line) {
srchns = option.slice(7).split('|');
continue;
}
if ( option === 'first-party' || option === '1p' ) {
if ( (option === 'first-party' || option === '1p') && deshn !== '' ) {
srchns.push(µBlock.URI.domainFromHostname(deshn) || deshn);
continue;
}