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: Decoder does not decode innerxml when using a TokenReader #39645

Open
hgoes opened this issue Jun 17, 2020 · 1 comment
Open

encoding/xml: Decoder does not decode innerxml when using a TokenReader #39645

hgoes opened this issue Jun 17, 2020 · 1 comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@hgoes
Copy link

hgoes commented Jun 17, 2020

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

1.14.4

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/hgoes/.cache/go-build"
GOENV="/home/hgoes/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY="git.engelvoelkers.com"
GONOSUMDB="git.engelvoelkers.com"
GOOS="linux"
GOPATH="/home/hgoes/go"
GOPRIVATE="git.engelvoelkers.com"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build309819268=/tmp/go-build -gno-record-gcc-switches"

What did you do?

When using encoding/xml.NewTokenDecoder, the decoder fails to fill fields marked ",innerxml".

Here's an example: https://play.golang.org/p/57xVMNiafsB

Removing the second assignment to the decoder gives the desired output.

What did you expect to see?

The inner XML of the test element

What did you see instead?

empty string

Diagnosis

I've debugged this a bit and I'm fairly certain that the problem is that the "innerxml" feature relies on the internal saved state of the Decoder which is not updated when using a TokenReader. The solution would be to serialize the resulting token into the saved field in the Decoder.rawToken function.

@andybons andybons changed the title encoding/xml.Decoder does not decode innerxml when using a TokenReader encoding/xml: Decoder does not decode innerxml when using a TokenReader Jun 17, 2020
@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 17, 2020
@andybons andybons added this to the Unplanned milestone Jun 17, 2020
@andybons
Copy link
Member

@rsc

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

2 participants