-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: Decoder does not handle external entities correctly #4196
Labels
Milestone
Comments
Fixed at tip, will be in Go 1.1. Not sure when it was fixed, but http://play.golang.org/p/-szb21L82T works for me (see below). I agree that the sandbox at Go 1.0.3 still has the bug. g% cat x.go package main import ( "encoding/xml" "fmt" "io" "strings" ) func main() { docBook := `<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [<!ENTITY preface SYSTEM "preface.xml"> <!ENTITY town-and-country SYSTEM "town-and-country.xml"> ]> <article> &preface; &town-and-country; </article>` decoder := xml.NewDecoder(strings.NewReader(docBook)) decoder.Strict = false for { token, err := decoder.Token() if err != nil && err != io.EOF { fmt.Printf("Error! Decoding XML failed: %v\n", err) break } if token == nil { break } switch element := token.(type) { case xml.CharData: fmt.Printf("%s\n", element) } } } g% go run x.go &preface; &town-and-country; g% Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
by yogischogi:
The text was updated successfully, but these errors were encountered: