Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main_frame request treated as third-party due to initiator/originUrl field #1797

Closed
eugenioemmolo opened this issue Mar 23, 2021 · 4 comments · Fixed by #1805
Closed

Main_frame request treated as third-party due to initiator/originUrl field #1797

eugenioemmolo opened this issue Mar 23, 2021 · 4 comments · Fixed by #1805

Comments

@eugenioemmolo
Copy link
Contributor

eugenioemmolo commented Mar 23, 2021

Package involved: WebExtenstion Adblocker
User Agent: Chrome 89.0.4389.90, Firefox 86.0.1

Within webRequest.onBeforeRequest callback context, I noticed that a main_frame request is flagged as third-party if the initiator/originUrl field is defined and its domain does not match the domain extracted from the request URL.

To clarify the scenario:

  // Defining details as:
  const details = {
    frameId: 0
    initiator: "https://example.com" // chrome case, "originUrl" if Firefox
    method: "GET"
    parentFrameId: -1
    requestId: "1"
    tabId: 1
    timeStamp: 1234
    type: "main_frame"
    url: "https://www.github.com/"
  }
  
  const request = fromWebRequestDetails(details);
  
  // request content would be:
  {
    domain: "github.com"
    entityHashes: undefined
    hostname: "www.github.com"
    hostnameHashes: undefined
    id: "1"
    isFirstParty: false
    isHttp: false
    isHttps: true
    isSupported: true
    isThirdParty: true  // because 'example.com' !== 'github.com'
    [...]
  }
@eugenioemmolo eugenioemmolo changed the title Main_frame request treated as third-party due to initiator field Main_frame request treated as third-party due to initiator/originUrl field Mar 23, 2021
@remusao
Copy link
Collaborator

remusao commented Mar 24, 2021

Hi @eugenioemmolo,

Thanks for opening an issue. I think it might make sense to not consider main_frame requests as being third-party from this function: https://github.com/cliqz-oss/adblocker/blob/master/packages/adblocker/src/request.ts#L187. What do you think? Would you be willing to make a pull request with the change? I am unfortunately not able to spend a lot of time on this at the moment.

Best,
Rémi

@eugenioemmolo
Copy link
Contributor Author

Hi @remusao,

Thank you for your quick reply. It is fine for me to contribute to the development of this great library.
I agree with your suggestion, I think the function you mentioned could always consider main_frame requests as being first-party.
I'll make a pull request with the change.

Regards
Eugenio

@remusao
Copy link
Collaborator

remusao commented Mar 25, 2021

Thanks again @eugenioemmolo, the fix is released as part of https://github.com/cliqz-oss/adblocker/releases/tag/v1.20.4

@eugenioemmolo
Copy link
Contributor Author

Thank you @remusao for the speedy review and release. Very glad to have given a little contribution :).
Best,
Eugenio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants