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

html/template: "application/ld+json" MIME type is not understood as JS #26053

Closed
eklitzke opened this issue Jun 25, 2018 · 3 comments
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@eklitzke
Copy link
Contributor

The text/html package does not understand the "application/ld+json" MIME type to be JS. This is a standard format endorsed by the W3C and various search engines. Search engines like Google require this data to be inline in a page's HTML using a tag like <script type="application/ld+json">JSON DATA HERE</script>, so it is important for the text/html template engine to be aware of how to escape JSON-LD data, as the data cannot be placed in an external script file. For more information on JSON-LD see [1] and [2].

I plan to submit a trivial PR to add json+ld support to text/html, but I am creating a GitHub issue first to describe the issue as per the contribution policy.

[1] https://en.wikipedia.org/wiki/JSON-LD
[2] https://developers.google.com/search/docs/guides/intro-structured-data

eklitzke added a commit to eklitzke/go that referenced this issue Jun 25, 2018
This change teaches the text/html package to understand the
"application/ld+json" MIME type (used for JSON-LD data) as Javascript, so it can
be escaped contextually.

Fixes golang#26053
eklitzke added a commit to eklitzke/go that referenced this issue Jun 25, 2018
Teach the text/html package to understand the "application/ld+json" MIME
type (used for JSON-LD data) as JS, so it can be apply the correct contextual
escaping.

Fixes golang#26053
@gopherbot
Copy link

Change https://golang.org/cl/120835 mentions this issue: text/html: MIME type "application/ld+json: should be escaped as JS

@bradfitz bradfitz added this to the Go1.12 milestone Jun 25, 2018
@bradfitz bradfitz added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Jun 25, 2018
@bradfitz
Copy link
Contributor

/cc @mikesamuel @FiloSottile

@odeke-em odeke-em changed the title text/html: "application/ld+json" MIME type is not understood as JS html/template: "application/ld+json" MIME type is not understood as JS Jun 26, 2018
@FiloSottile
Copy link
Contributor

A JSON-LD document must be a valid JSON document as described in [RFC4627].

For the purposes of text/html, this is indeed JSON. LGTM.

@FiloSottile FiloSottile added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. labels Jun 26, 2018
@golang golang locked and limited conversation to collaborators Dec 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants