ampproject / ampproject/amp-toolbox-php
ampersand sign converted into unicode when added to analytics config.
- Dominant language
- PHP
- Stars
- 74
- Forks
- 25
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 3
Description
**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
```json
{
"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**
```json
{
"requests": {
"custom_params": "cp1=test\u0026cp2=test"
},
"vars": {
"env": "-preproduction"
},
"triggers": {
"trackConsent": {
"on": "visible",
"request": "impression"
}
}
}
```
**Screenshot**
| Input | Output |
| ------------- | ------------- |
|  |  |
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce the analytics configuration steps with the AMP optimizer enabled, then trace how the JSON config is processed and emitted. Confirm the fix by checking that the ampersand in custom_params remains unchanged in the generated output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100