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: decoding XML with entities not supported #30983

Closed
kunalgrover05 opened this issue Mar 21, 2019 · 2 comments
Closed

encoding/xml: decoding XML with entities not supported #30983

kunalgrover05 opened this issue Mar 21, 2019 · 2 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@kunalgrover05
Copy link

kunalgrover05 commented Mar 21, 2019

What version of Go are you using (go version)?

$ go version
1.9

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

Linux AMD64

go env Output
$ go env

What did you do?

XML entity support

	s := "<?xml version='1.0' encoding='ISO-8859-1'?><!DOCTYPE foo [ <!ENTITY test 'hello' > ]><Users><User><Name>&test;</Name></User></Users>"

	reader := strings.NewReader(s)
	decoder := xml.NewDecoder(reader)
	decoder.CharsetReader = charset.NewReaderLabel

	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)
		}
	}

Exception

Error! Decoding XML failed: XML syntax error on line 1: invalid character entity &test;

Parsed data with decoder.Strict = false

&pwnd;

What did you expect to see?

Entities and External entities to be processed as per https://www.w3.org/TR/xml/#sec-entity-decl

What did you see instead?

@mvdan
Copy link
Member

mvdan commented Mar 22, 2019

I'm not experienced with XML, but have you had a look at #4196? And possibly #20614 too, since I see some extra whitespace in there.

@katiehockman katiehockman changed the title encoding/xml Decoding XML with entities not supported encoding/xml: decoding XML with entities not supported Mar 22, 2019
@julieqiu julieqiu added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Apr 22, 2019
@julieqiu julieqiu added this to the Go1.13 milestone Apr 22, 2019
@gopherbot
Copy link
Contributor

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@golang golang locked and limited conversation to collaborators May 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants