Skip to content

Use Reflect for script.src #453

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

Merged
merged 2 commits into from
Apr 20, 2023
Merged

Use Reflect for script.src #453

merged 2 commits into from
Apr 20, 2023

Conversation

jonathanKingston
Copy link
Contributor

Use reflect for script.src as some scripts bind this to call getAttribute causing a stack overflow.

Follow the steps in: duckduckgo/duckduckgo-privacy-extension#1913

cookielaw is exempted from stack tracing and pandadoc are exceptions; when they're enabled you'll see the stack overflow mentioned in the issue.

When you place a debugger within the class you see cookielaw has overriden us:

Object.getOwnPropertyDescriptor(this, 'src').get.toString()
'function(){return a.getAttribute("src")||""}'
Object.getOwnPropertyDescriptor(this, 'src').set.toString()
'function(c){var b="";"string"==typeof c?b=c:c instanceof Object&&(b=c.toString());b=n(b);!b.categoryIds.length&&!b.vsCatIds.length||\n"script"!==d[0].toLowerCase()||p(a)||m(b.categoryIds,b.vsCatIds)||q(a)?!b.categoryIds.length||-1===w.indexOf(d[0].toLowerCase())||p(a)||m(b.categoryIds,b.vsCatIds)||q(a)?f("src",c):(a.removeAttribute("src"),f("data-src",c),c=a.getAttribute("class"),c||(c=B(b.categoryIds,c||"",b.vsCatIds),f("class",c))):(f("type","text/plain"),f("src",c));return!0}'

We're doing the reverse wishing to call this[name] which in turn calls getAttribute creating the infinite loop.

@jonathanKingston jonathanKingston merged commit de2e504 into main Apr 20, 2023
@jonathanKingston jonathanKingston deleted the jkt/stackOverflow branch April 20, 2023 18:49
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 this pull request may close these issues.

2 participants