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 #35389

TidDl3R opened this issue Nov 6, 2019 · 2 comments

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

TidDl3R opened this issue Nov 6, 2019 · 2 comments


Copy link

@TidDl3R TidDl3R commented Nov 6, 2019

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

$ go version
go version go1.13.3 darwin/amd64

Does this issue reproduce with the latest release?


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

go env Output
$ go env

What did you do?

I parsed the XML with the entity, but the part with the entity was not parsed (the entity value is in the DTD).
I checked the documentation and set xml.Decoder.Strict to false. What appears is the entity itself, not the value of the entity.

This is my program:

What did you expect to see?

What did you see instead?

When d.Strict = true, there is nothing.
When d.Strict = false, output:

Copy link

@bcmills bcmills commented Nov 6, 2019

See previously #4196, #30983, #20614.

@bcmills bcmills modified the milestones: Backlog, Unplanned Nov 6, 2019
Copy link

@TidDl3R TidDl3R commented Nov 6, 2019

See previously #4196, #30983, #20614.

Thank you very much for your reply, but it doesn't seem to have been resolved.

#4196 is a parsing bug, but it only outputs the value in XML, not the value of entity. So it didn't solve my problem.
#30983 is a coding problem, it uses iso-8859-1 coding and results in parsing errors. This problem has nothing to do with entities.
#20614 seems to have nothing to do with parsing entities. It looks like it's caused by parsing characters such as spaces.

What I expect is when parsing the following XML:

<!DOCTYPE server [ <!ENTITY n 'hello' > ]>

The value of name can be hello, not &n; It doesn't look like that at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.