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

CMP Stub postMessageEventHandler should prevent attempting to parse unrelated messages #317

Open
nealrosen opened this issue Jan 13, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@nealrosen
Copy link

Version
1.3.1

Module (core, cmpapi, cli, stub, or testing)
stub

Describe with reproduction steps – What is the expected behavior?
On some sites, there can be a large number of postMessage calls made for various purposes unrelated to the CMP. As a result, the stub attempts to parse a lot of messages that are not JSON formatted and/or are not intended for the CMP. This results in many caught exceptions thrown. While not directly user impacting, this takes up unnecessary CPU cycles and makes debugging with caught exceptions very difficult with the caught exception "noise" coming from the CMP.

This could be mitigated significantly with a couple simple checks against string message payloads before attempting to parse them as JSON. A couple simple checks might be

  1. Check that the payload starts with a curly bracket
  2. Check that the payload contains "tcfapi"
@nealrosen nealrosen added the bug Something isn't working label Jan 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant