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/json: Extra space in Decoder.Token SyntaxError messages #26587

Closed
PhilipBorgesen opened this issue Jul 25, 2018 · 5 comments
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@PhilipBorgesen
Copy link
Contributor

Decoder.Token returns SyntaxError with messages containing double spaces after the quoted character (via Decoder.tokenError):

func (dec *Decoder) tokenError(c byte) (Token, error) {
	var context string
	switch dec.tokenState {
	case tokenTopValue:
		context = " looking for beginning of value"
	case tokenArrayStart, tokenArrayValue, tokenObjectValue:
		context = " looking for beginning of value"
	case tokenArrayComma:
		context = " after array element"
	case tokenObjectKey:
		context = " looking for beginning of object key string"
	case tokenObjectColon:
		context = " after object key"
	case tokenObjectComma:
		context = " after object key:value pair"
	}
	return nil, &SyntaxError{"invalid character " + quoteChar(c) + " " + context, dec.offset()}
}

I found this when building a test suite under go version go1.10 darwin/amd64, but it is still an issue as per current HEAD of the master branch: https://github.com/golang/go/blob/master/src/encoding/json/stream.go#L474

I intend to contribute a patch, this issue is mainly to serve as reference and avoid duplication of effort (however small it may be).

@gopherbot
Copy link

Change https://golang.org/cl/125775 mentions this issue: encoding/json: eliminate superfluous space in Decoder.Token error messages

@mvdan
Copy link
Member

mvdan commented Jul 25, 2018

This isn't a regression from 1.10 and we're very late into the code freeze, so I'm putting this down for 1.12. Thanks for the fix!

@mvdan mvdan added this to the Go1.12 milestone Jul 25, 2018
@mvdan mvdan added the NeedsFix The path to resolution is known, but the work has not been done. label Jul 25, 2018
@PhilipBorgesen
Copy link
Contributor Author

You're welcome!

Do I need to do anything when 1.11 is released to continue beyond re-merging from master?

@mvdan
Copy link
Member

mvdan commented Jul 25, 2018

You don't need to do anything other than respond to reviews and fix any conflicts if they emerge. We should get to this CL along with all the others waiting for the freeze to be over.

@PhilipBorgesen
Copy link
Contributor Author

Ok, thank you!

@golang golang locked and limited conversation to collaborators Aug 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants