Skip to content

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

@candlerb

Description

@candlerb

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions