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

Comments

Projects
None yet
4 participants
@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

This comment has been minimized.

Copy link
Contributor

mibk commented Sep 2, 2015

@gopherbot

This comment has been minimized.

Copy link

gopherbot commented Sep 2, 2015

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

@rsc rsc closed this 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.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.