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

thisArg.collectedHeaders is undefined #349

Closed
piquark6046 opened this issue Aug 3, 2023 · 4 comments
Closed

thisArg.collectedHeaders is undefined #349

piquark6046 opened this issue Aug 3, 2023 · 4 comments

Comments

@piquark6046
Copy link
Member

piquark6046 commented Aug 3, 2023

After aagag.com#%#//scriptlet('prevent-xhr', 'pagead2.googlesyndication.com/pagead/js/adsbygoogle.js') in AdGuard Browser Extension on Firefox, an Uncaught TypeError: can't access property "length", thisArg.collectedHeaders is undefined error is raised.

const getHeaderWrapper = (target, thisArg, args) => {
if (!thisArg.collectedHeaders.length) {
return null;
}
// The search for the header name is case-insensitive
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/getResponseHeader
const searchHeaderName = args[0].toLowerCase();
const matchedHeader = thisArg.collectedHeaders.find((header) => {
const headerName = header[0].toLowerCase();
return headerName === searchHeaderName;
});
return matchedHeader
? matchedHeader[1]
: null;
};

Instead of simply using logical not operator (!), please use typeof operator to test before it.

Environment

@piquark6046
Copy link
Member Author

AdGuard Browser Extension 4.1.57 on Firefox is not affected.

@AdamWr
Copy link
Member

AdamWr commented Aug 3, 2023

I suppose that it might be the same issue as here - #347 (comment)

@piquark6046
Copy link
Member Author

I think that this issue has to be prioritized to a upper class because this issue causes breakages if prevent-xhr scriptlet is applied in a webpage.
Confirmed a website having this issue:

@AdamWr
Copy link
Member

AdamWr commented Aug 19, 2023

It should be already fixed in scriptlets library version 1.9.62.
The latest scriptlets library (1.9.62) is already in AdGuard AdBlocker extension 4.2.151 and as far as I can see, it works correctly on these websites.

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

No branches or pull requests

5 participants