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

ampersand sign converted into unicode when added to analytics config. #529

Open
milindmore22 opened this issue Aug 11, 2022 · 1 comment

Comments

@milindmore22
Copy link

milindmore22 commented Aug 11, 2022

Bug Description

A user reported on support forums that the & is being converted to Unicode character \u0026 when being added to the analytics config.

After disabling optimizer it did output correctly
add_filter( 'amp_enable_optimizer', '__return_false' );

Steps to reproduce
You can reproduce using the AMP plugin for WordPress, steps assuming that you have WordPress site with AMP plugin installed

Step 1 : Login as Admin
Step 2: Goto AMP->Settings->Analytics
Step 3: Enter the type as "test" (you can add anything as type was unknow from support topics)
Step 4: add JSON config as below

{
  "requests": {
    "custom_params": "cp1=test&cp2=test"
  },
  "vars": {
    "env": "-preproduction"
  },
  "triggers": {
    "trackConsent": {
      "on": "visible",
      "request": "impression"
    }
  }
}

Expected Output
Same output as entered in config.

Current Behaviour

{
  "requests": {
    "custom_params": "cp1=test\u0026cp2=test"
  },
  "vars": {
    "env": "-preproduction"
  },
  "triggers": {
    "trackConsent": {
      "on": "visible",
      "request": "impression"
    }
  }
}

Screenshot

Input Output
image image
@westonruter
Copy link
Member

westonruter commented Aug 11, 2022

I don't think this is a problem. In JavaScript, \u0026 is the encoding of an ampersand the same way that & or & is the way to encode the ampersand in HTML. In CSS, the encoding of & is \0026. They all get decoded in the end as &.

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