ampproject / ampproject/amp-toolbox

Encoding JSON values broke JSON config in amp-analytics tag #16261

Open
#898 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
459
Forks
242
PR merge metrics
No merged PRs in 30d

Description

# Bug report
AMP Optimizer encode `&` in JSON inside amp-analytics tag
## Describe the bug
Here is the code (this is not the complete code, only the problem area):
```


</amp-analytics>
```
And here is the result:

<img width="1102" alt="Screenshot 2020-08-17 at 13 20 09" src="https://user-images.githubusercontent.com/3934846/90406920-20573300-e0a6-11ea-9f2b-1f42eefc12ae.png">

If I understand correctly that behavior starts from that PR — [Encode JSON values](https://github.com/ampproject/amp-toolbox/pull/649)

## To Reproduce

1. Go to https://github.com/vladbesson/amp-nextjs-encoding-json-issue
2. Clone and run the project
3. http://localhost:3000/
4. Check the result in code inspector
<img width="894" alt="Screenshot 2020-08-17 at 17 01 02" src="https://user-images.githubusercontent.com/3934846/90410925-48956080-e0ab-11ea-95e5-188a5b79285f.png">

## Expected behavior

I tried to reproduce it in different sandboxes — react non-amp and with amp — and everywhere it works just fine, as expected

<img width="1207" alt="Screenshot 2020-08-17 at 13 35 17" src="https://user-images.githubusercontent.com/3934846/90407495-e33f7080-e0a6-11ea-8a94-571a6556c36b.png">

## System information

- OS: macOS Catalina
- Browse: Chrome 84.0.4147.125
- Version of Next.js: 9.4.2
- Version of Node.js: 12.18.2

Contributor guide

Open the contributing guide

Research direction

Clone and run the reproduction project at https://github.com/vladbesson/amp-nextjs-encoding-json-issue, then open http://localhost:3000/ and inspect the generated amp-analytics markup. Compare the result with the source JSON and the expected behavior shown in the issue; done means the JSON retains the intended amp-analytics values and placeholders.

Written by the indexing model from the issue text.

Assessment

Tech stack
html
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.