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: parser gives "unexpected EOF" error on trailing whitespace #674

Closed
gopherbot opened this Issue Mar 18, 2010 · 1 comment

Comments

Projects
None yet
2 participants
@gopherbot
Copy link

gopherbot commented Mar 18, 2010

by consalus:

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.
@rsc

This comment has been minimized.

Copy link
Contributor

rsc commented Apr 29, 2010

Comment 1:

This issue was closed by revision 0485ba7.

Status changed to Fixed.

@mikioh 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

@golang golang locked and limited conversation to collaborators Jun 24, 2016

This issue was closed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.
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.