mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-02 17:19:38 +02:00
This commit is contained in:
parent
8eb7794965
commit
ee89f88265
@ -30,7 +30,7 @@
|
|||||||
// https://github.com/gorhill/uBlock/issues/2950
|
// https://github.com/gorhill/uBlock/issues/2950
|
||||||
// Firefox 56 does not normalize URLs to ASCII, uBO must do this itself.
|
// Firefox 56 does not normalize URLs to ASCII, uBO must do this itself.
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=945240
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=945240
|
||||||
let evalMustPunycode = function() {
|
const evalMustPunycode = function() {
|
||||||
return vAPI.webextFlavor.soup.has('firefox') &&
|
return vAPI.webextFlavor.soup.has('firefox') &&
|
||||||
vAPI.webextFlavor.major < 57;
|
vAPI.webextFlavor.major < 57;
|
||||||
};
|
};
|
||||||
@ -39,16 +39,16 @@
|
|||||||
|
|
||||||
// The real actual webextFlavor value may not be set in stone, so listen
|
// The real actual webextFlavor value may not be set in stone, so listen
|
||||||
// for possible future changes.
|
// for possible future changes.
|
||||||
window.addEventListener('webextFlavor', function() {
|
window.addEventListener('webextFlavor', ( ) => {
|
||||||
mustPunycode = evalMustPunycode();
|
mustPunycode = evalMustPunycode();
|
||||||
}, { once: true });
|
}, { once: true });
|
||||||
|
|
||||||
let denormalizeTypes = function(aa) {
|
const denormalizeTypes = function(aa) {
|
||||||
if ( aa.length === 0 ) {
|
if ( aa.length === 0 ) {
|
||||||
return Array.from(vAPI.net.validTypes);
|
return Array.from(vAPI.net.validTypes);
|
||||||
}
|
}
|
||||||
let out = new Set(),
|
const out = new Set();
|
||||||
i = aa.length;
|
let i = aa.length;
|
||||||
while ( i-- ) {
|
while ( i-- ) {
|
||||||
let type = aa[i];
|
let type = aa[i];
|
||||||
if ( vAPI.net.validTypes.has(type) ) {
|
if ( vAPI.net.validTypes.has(type) ) {
|
||||||
@ -57,13 +57,16 @@
|
|||||||
if ( type === 'image' && vAPI.net.validTypes.has('imageset') ) {
|
if ( type === 'image' && vAPI.net.validTypes.has('imageset') ) {
|
||||||
out.add('imageset');
|
out.add('imageset');
|
||||||
}
|
}
|
||||||
|
if ( type === 'sub_frame' ) {
|
||||||
|
out.add('object');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Array.from(out);
|
return Array.from(out);
|
||||||
};
|
};
|
||||||
|
|
||||||
let punycode = self.punycode;
|
const punycode = self.punycode;
|
||||||
let reAsciiHostname = /^https?:\/\/[0-9a-z_.:@-]+[/?#]/;
|
const reAsciiHostname = /^https?:\/\/[0-9a-z_.:@-]+[/?#]/;
|
||||||
let parsedURL = new URL('about:blank');
|
const parsedURL = new URL('about:blank');
|
||||||
|
|
||||||
vAPI.net.normalizeDetails = function(details) {
|
vAPI.net.normalizeDetails = function(details) {
|
||||||
if ( mustPunycode && !reAsciiHostname.test(details.url) ) {
|
if ( mustPunycode && !reAsciiHostname.test(details.url) ) {
|
||||||
@ -74,7 +77,7 @@
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let type = details.type;
|
const type = details.type;
|
||||||
|
|
||||||
// https://github.com/gorhill/uBlock/issues/1493
|
// https://github.com/gorhill/uBlock/issues/1493
|
||||||
// Chromium 49+/WebExtensions support a new request type: `ping`,
|
// Chromium 49+/WebExtensions support a new request type: `ping`,
|
||||||
@ -88,10 +91,24 @@
|
|||||||
details.type = 'image';
|
details.type = 'image';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/345
|
||||||
|
// Re-categorize an embedded object as a `sub_frame` if its
|
||||||
|
// content type is that of a HTML document.
|
||||||
|
if ( type === 'object' && Array.isArray(details.responseHeaders) ) {
|
||||||
|
for ( const header of details.responseHeaders ) {
|
||||||
|
if ( header.name.toLowerCase() === 'content-type' ) {
|
||||||
|
if ( header.value.startsWith('text/html') ) {
|
||||||
|
details.type = 'sub_frame';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
vAPI.net.denormalizeFilters = function(filters) {
|
vAPI.net.denormalizeFilters = function(filters) {
|
||||||
let urls = filters.urls || [ '<all_urls>' ];
|
const urls = filters.urls || [ '<all_urls>' ];
|
||||||
let types = filters.types;
|
let types = filters.types;
|
||||||
if ( Array.isArray(types) ) {
|
if ( Array.isArray(types) ) {
|
||||||
types = denormalizeTypes(types);
|
types = denormalizeTypes(types);
|
||||||
|
Loading…
Reference in New Issue
Block a user