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: escape first char for XML #12496

Closed
alexandrestein opened this issue Sep 4, 2015 · 4 comments
Closed

html/template: escape first char for XML #12496

alexandrestein opened this issue Sep 4, 2015 · 4 comments

Comments

@alexandrestein
Copy link

It looks like HTML template escape characters out of the variable.
In my case I tried to build a simple XML file, and the the first charset is escaped.
http://play.golang.org/p/PUylzjxJfW

It looks like a bug to me.

Best regards.

@bradfitz bradfitz changed the title HTML template escape first char for XML html/template: escape first char for XML Sep 4, 2015
@bradfitz
Copy link
Contributor

bradfitz commented Sep 4, 2015

Probably because this is the HTML templating package and you're trying to produce XML. I suspect that it doesn't know how to parse the <?foo> directives with the question mark there.

You probably want to use the text/template package instead, if you're not going to be taking advantage of any of the HTML auto-escaping features.

/cc @robpike @adg to decide what (if anything) to do here.

@alexandrestein
Copy link
Author

I made it with encoding/xml package but the behavior is not as expected.

@robpike
Copy link
Contributor

robpike commented Sep 4, 2015

I believe Brad answered the question. Use text/template not html/template, and escape manually.

@robpike robpike closed this as completed Sep 4, 2015
@alexandrestein
Copy link
Author

Ok, but it's a bug.
That's it.

@golang golang locked and limited conversation to collaborators Sep 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants