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/xml: allows invalid comments #11112

Closed
dvyukov opened this issue Jun 7, 2015 · 2 comments
Closed

encoding/xml: allows invalid comments #11112

dvyukov opened this issue Jun 7, 2015 · 2 comments
Milestone

Comments

@dvyukov
Copy link
Member

dvyukov commented Jun 7, 2015

The following program crashes with the panic:

package main

import (
    "encoding/xml"
)

type X struct {
    D string `xml:",comment"`
}

func main() {
    data := []byte("<X><!------></X>")
    v := new(X)
    if xml.Unmarshal(data, v) != nil {
        return
    }
    if _, err := xml.Marshal(v); err != nil {
        panic(err)
    }
}
panic: xml: comments must not contain "--"
goroutine 1 [running]:
main.main()
    xml.go:18 +0x129

The XML is malformed, as per XML spec:

http://www.w3.org/TR/REC-xml/#sec-comments
Comment ::= ''

Unmarshal must reject it.

on commit 306f8f1

@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Jun 7, 2015
@mibk
Copy link
Contributor

mibk commented Sep 2, 2015

See CL https://golang.org/cl/14173.

@gopherbot
Copy link

CL https://golang.org/cl/14173 mentions this issue.

@rsc rsc closed this as completed in 97c859f Nov 25, 2015
@golang golang locked and limited conversation to collaborators Nov 27, 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