mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-18 08:52:26 +02:00
Ensure about:
frames use proper origin
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/688 `about:` frames need to lookup and use the inherited origin from their parent browsing context for proper lookup of cosmetic filters.
This commit is contained in:
parent
779fde8f3a
commit
3b72c7cb04
@ -118,6 +118,26 @@ vAPI.contentScript = true;
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/688#issuecomment-663657508
|
||||||
|
{
|
||||||
|
let location = self.location;
|
||||||
|
if ( location.protocol === 'about:' ) {
|
||||||
|
try {
|
||||||
|
let context = self;
|
||||||
|
do {
|
||||||
|
context = context.parent;
|
||||||
|
location = context.location;
|
||||||
|
} while ( context !== self.top && location.protocol === 'about:' );
|
||||||
|
} catch(ex) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vAPI.pageLocation = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
/******************************************************************************/
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
vAPI.userStylesheet = {
|
vAPI.userStylesheet = {
|
||||||
added: new Set(),
|
added: new Set(),
|
||||||
removed: new Set(),
|
removed: new Set(),
|
||||||
@ -1765,8 +1785,8 @@ vAPI.injectScriptlet = function(doc, text) {
|
|||||||
vAPI.bootstrap = function() {
|
vAPI.bootstrap = function() {
|
||||||
vAPI.messaging.send('contentscript', {
|
vAPI.messaging.send('contentscript', {
|
||||||
what: 'retrieveContentScriptParameters',
|
what: 'retrieveContentScriptParameters',
|
||||||
url: window.location.href,
|
url: vAPI.pageLocation.href,
|
||||||
isRootFrame: window === window.top,
|
isRootFrame: self === self.top,
|
||||||
charset: document.characterSet,
|
charset: document.characterSet,
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
bootstrapPhase1(response);
|
bootstrapPhase1(response);
|
||||||
|
@ -524,11 +524,15 @@ const µb = µBlock;
|
|||||||
|
|
||||||
const retrieveContentScriptParameters = function(senderDetails, request) {
|
const retrieveContentScriptParameters = function(senderDetails, request) {
|
||||||
if ( µb.readyToFilter !== true ) { return; }
|
if ( µb.readyToFilter !== true ) { return; }
|
||||||
const { url, tabId, frameId } = senderDetails;
|
const { url: senderURL, tabId, frameId } = senderDetails;
|
||||||
if ( url === undefined || tabId === undefined || frameId === undefined ) {
|
if (
|
||||||
|
tabId === undefined ||
|
||||||
|
frameId === undefined ||
|
||||||
|
senderURL === undefined ||
|
||||||
|
senderURL !== request.url && senderURL.startsWith('about:') === false
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( request.url !== url ) { return; }
|
|
||||||
const pageStore = µb.pageStoreFromTabId(tabId);
|
const pageStore = µb.pageStoreFromTabId(tabId);
|
||||||
if ( pageStore === null || pageStore.getNetFilteringSwitch() === false ) {
|
if ( pageStore === null || pageStore.getNetFilteringSwitch() === false ) {
|
||||||
return;
|
return;
|
||||||
@ -714,7 +718,7 @@ const onMessage = function(request, sender, callback) {
|
|||||||
xhr.responseType = 'text';
|
xhr.responseType = 'text';
|
||||||
xhr.onload = function() {
|
xhr.onload = function() {
|
||||||
this.onload = null;
|
this.onload = null;
|
||||||
var i18n = {
|
const i18n = {
|
||||||
bidi_dir: document.body.getAttribute('dir'),
|
bidi_dir: document.body.getAttribute('dir'),
|
||||||
create: vAPI.i18n('pickerCreate'),
|
create: vAPI.i18n('pickerCreate'),
|
||||||
pick: vAPI.i18n('pickerPick'),
|
pick: vAPI.i18n('pickerPick'),
|
||||||
|
@ -211,10 +211,12 @@ const processTimer = new vAPI.SafeAnimationFrame(( ) => {
|
|||||||
|
|
||||||
if ( toLog.length === 0 ) { return; }
|
if ( toLog.length === 0 ) { return; }
|
||||||
|
|
||||||
|
const location = vAPI.pageLocation || self.location;
|
||||||
|
|
||||||
vAPI.messaging.send('scriptlets', {
|
vAPI.messaging.send('scriptlets', {
|
||||||
what: 'logCosmeticFilteringData',
|
what: 'logCosmeticFilteringData',
|
||||||
frameURL: window.location.href,
|
frameURL: location.href,
|
||||||
frameHostname: window.location.hostname,
|
frameHostname: location.hostname,
|
||||||
matchedSelectors: toLog,
|
matchedSelectors: toLog,
|
||||||
});
|
});
|
||||||
//console.timeEnd('dom logger/scanning for matches');
|
//console.timeEnd('dom logger/scanning for matches');
|
||||||
|
Loading…
Reference in New Issue
Block a user