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

encoding/json: shows #ZgotmplZ in a custom attribute with name "data-data" but not with "data-go" #12648

Closed
emilgpa opened this issue Sep 16, 2015 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@emilgpa
Copy link

emilgpa commented Sep 16, 2015

The error occurs when marshal a struct in a HTML inside of a custom attribute with name data-data but not with other name (for example, data-go)

http://play.golang.org/p/Wui-dfKLDx

@ianlancetaylor ianlancetaylor changed the title shows #ZgotmplZ in a custom attribute with name "data-data" but not with "data-go" encoding/json: shows #ZgotmplZ in a custom attribute with name "data-data" but not with "data-go" Sep 16, 2015
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Sep 16, 2015
@nussjustin
Copy link
Contributor

I took a look this since I'm currently playing with the html/template package.

When checking the type of known attributes the html/template package removes "data-" prefixes so it can handle things like data-href or data-src as URLs or prevent unsafe values for fields like data-method. So data-data becomes only data (at least for the type checking). Since data is a known attribute used to specify the URLs for <object>'s the parser treats it, and thus data-data, as URL.

So I'd say this works as intended. But we should at least update the documentation to state that data-* attributes and attributes with namespaces are handled as if they had no data- prefix / namespace.

@gopherbot
Copy link

Change https://golang.org/cl/79895 mentions this issue: html/template: document handling of namespaced and data- attributes

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 16, 2019
@golang golang locked and limited conversation to collaborators Sep 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants