Skip to content

html/template: escape xmldesc as <?xml #3133

Closed
@ukai

Description

@ukai
What steps will reproduce the problem?
package main
import (
    "html/template"
    "os"
)
func main() {
    t1, _ := template.New("xml").Parse(`<?xml version="1.0"?><feed></feed>`)
    t1.Execute(os.Stdout, nil)
}

What is the expected output?

<?xml vesion="1.0"?><feed></feed>

What do you see instead?

&lt;?xml version="1.0"?><feed></feed>

Which compiler are you using (5g, 6g, 8g, gccgo)?

6g

Which operating system are you using?

linux

Which revision are you using?  (hg identify)

767b6229d4dc tip

Please provide any additional information below.

I'm not sure it's ok to use html/template for xml generation, but encoding/xml provides
only xml parsing, and we may need lots of escape with text/template.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions