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

[adblocker-electron] A form element with <input name="id" /> throws "An object could not be cloned" error #3327

Open
jayakrishnankp opened this issue Jul 5, 2023 · 1 comment

Comments

@jayakrishnankp
Copy link

jayakrishnankp commented Jul 5, 2023

Short Description

If a form contains an input element with name='id', adblocker-content/adblocker.ts throws a An object could not be cloned error.

More Context

  • I was trying to open this link https://www.thetoyshop.com/shop-by-age/6-year-olds/Mouse-Trap-Game/p/532476?queryId=204f7ae81453d250c1b3daac1f2f2281 in a BrowserView in my electron app with this adblocker enabled.

  • The adblocker throws an error: An object could not be cloned when we open the above link. Debugging the error it was found that the ipcRenderer in api/ipc-renderer.ts was trying to send an object which had an input element in the ids array.

  • Traced the call stack of ipcRenderer.send and this element is coming from the Meta's pixel tracking form which is a form element that contains an input with name=id.

  • When a form contains an input with name='id', the ids array generator in the extractFeaturesFromDOM method gets the input element instead of the form element's id because formElement.id will return the input element with name='id'

    const id = element.id;
    if (id) {
    ids.add(id);
    }

  • This causes the constructed ids array to have an input element which cannot be passed to structuredClone as it will throw.

Proposed Solution

Replace element.id (in api/ipc-renderer.ts/line:89) with element.getAttribute('id')

@jayakrishnankp jayakrishnankp changed the title [adblocker-electron] IPC sending an input element and throws "An object could not be cloned" error [adblocker-electron] A form element with <input name=id /> throws "An object could not be cloned" error Jul 5, 2023
@jayakrishnankp jayakrishnankp changed the title [adblocker-electron] A form element with <input name=id /> throws "An object could not be cloned" error [adblocker-electron] A form element with <input name="id" /> throws "An object could not be cloned" error Jul 5, 2023
@remusao
Copy link
Collaborator

remusao commented Jul 23, 2023

Hi @jayakrishnankp,

Thanks for taking the time to open this issue. This definitely looks like a bug and the approach you suggest seems reasonable. Would you be willing to open a PR with the change? I'd be happy to review and publish it.

Best,

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

No branches or pull requests

2 participants