diff options
| author | Constantin Konstantinidis <constantinkonstantinidis@gmail.com> | 2018-04-15 11:26:32 +0200 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2022-11-09 03:01:28 +0000 |
| commit | f13849a7af4c058caa6af14f7d3f9aa81982c124 (patch) | |
| tree | 6e67cfdb501e6df5f42b38a54fce2deef2376ce6 /src/encoding/xml/xml.go | |
| parent | b459166219b77857dc6d9366366b015d84e17bbe (diff) | |
| download | go-f13849a7af4c058caa6af14f7d3f9aa81982c124.tar.xz | |
encoding/xml: error when closing tag does not match opening tag
Comparing opening and closing tag is done using the prefix when available.
Documentation states that Token returns URI in the Space part of the Name.
Translation has been moved for the End tag before the namespace is removed
from the stack.
After closing a tag using a namespace, the valid namespace must be taken
from the opening tag. Tests added.
Fixes #20685
Change-Id: I4d90b19f7e21a76663f0ea1c1db6c6bf9fd2a389
Reviewed-on: https://go-review.googlesource.com/c/go/+/107255
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/encoding/xml/xml.go')
| -rw-r--r-- | src/encoding/xml/xml.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/encoding/xml/xml.go b/src/encoding/xml/xml.go index 50a91a897f..d4509dfc85 100644 --- a/src/encoding/xml/xml.go +++ b/src/encoding/xml/xml.go @@ -314,15 +314,14 @@ func (d *Decoder) Token() (Token, error) { } } + d.pushElement(t1.Name) d.translate(&t1.Name, true) for i := range t1.Attr { d.translate(&t1.Attr[i].Name, false) } - d.pushElement(t1.Name) t = t1 case EndElement: - d.translate(&t1.Name, true) if !d.popElement(&t1) { return nil, d.err } @@ -495,6 +494,8 @@ func (d *Decoder) popElement(t *EndElement) bool { return false } + d.translate(&t.Name, true) + // Pop stack until a Start or EOF is on the top, undoing the // translations that were associated with the element we just closed. for d.stk != nil && d.stk.kind != stkStart && d.stk.kind != stkEOF { |
