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: minor improvement to namespace mismatch in closing tag #48890

Closed
candlerb opened this issue Oct 9, 2021 · 2 comments
Closed

encoding/xml: minor improvement to namespace mismatch in closing tag #48890

candlerb opened this issue Oct 9, 2021 · 2 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@candlerb
Copy link

candlerb commented Oct 9, 2021

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

play.golang.org (1.17.2)

Does this issue reproduce with the latest release?

Yes

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

N/A

What did you do?

https://play.golang.org/p/2J4gNo_saN3

What did you expect to see?

Error message about closing tag being in wrong namespace

What did you see instead?

The error message is accurate:

panic: XML syntax error on line 4: element <foo> in space http://example.comclosed by </foo> in space 

However there are a couple of ways this could be improved.

  1. Add a whitespace separator before the words "closed by", so it doesn't crash into the namespace URI
  2. Put quotation marks around the namespace (or make the null namespace visible in some other way; or remove the words "in space" if the namespace is not set).

e.g. this would be better:

panic: XML syntax error on line 4: element <foo> in space "http://example.com" closed by </foo> in space ""

Reference: https://github.com/golang/go/blob/master/src/encoding/xml/xml.go#L502

@candlerb candlerb changed the title encoding/xml: minor improvement to closing tag error message encoding/xml: minor improvement to namespace mismatch in closing tag Oct 9, 2021
@candlerb
Copy link
Author

candlerb commented Oct 9, 2021

Here's an example of a different place which gives a better error message, saying "no name space" where there isn't one:
https://play.golang.org/p/uOWeDoGXW2g

panic: expected element <Edmx> in name space http://docs.oasis-open.org/odata/ns/edmx but have no name space

(and I think "name space" is clearer than just "space")

@toothrot toothrot added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 12, 2021
@toothrot toothrot added this to the Backlog milestone Oct 12, 2021
@gopherbot
Copy link

Change https://go.dev/cl/535535 mentions this issue: encoding/xml: display closing space in error message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants