You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not actually sure this is a bug; it might be a case of the parser being
more strict than other parsers I've been using. Might just be a feature
request.
What steps will reproduce the problem?
1. Try to parse any XML with a trailing newline or space.
Example test case for xml_test.go:
func TestTrailing(t *testing.T) {
input := `<FOO></FOO> `
p := NewParser(StringReader(input))
var err os.Error
for _, err = p.Token(); err == nil; _, err = p.Token() {
}
if err != os.EOF {
t.Fatalf("Should've gotten EOF, got %#v", err)
}
}
What is the expected output? What do you see instead?
The above test fails. I would expect it to pass.
What is your $GOOS? $GOARCH?
darwin 386
Which revision are you using? (hg identify)
6d84eccc9c31+ tip
Please provide any additional information below.
The issue seems to be that Parser.text() assumes a text section (even when
not quoted or cdata) to be terminated by something other than an EOF. If
there is trailing whitespace, the text() call from RawToken() will just keep
parsing it with mustgetc() until mustgetc() fails. If indeed this is
undesirable behavior, the mustgetc() could be replaced with just getc(),
then special case to not throw a syntax error and instead return nil, os.EOF
when we aren't in a quote or a cdata.
The text was updated successfully, but these errors were encountered:
mikioh
changed the title
xml parser gives "unexpected EOF" error on trailing whitespace
encoding/xml: parser gives "unexpected EOF" error on trailing whitespace
Jan 9, 2015
by consalus:
The text was updated successfully, but these errors were encountered: