-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
time: UnmarshalJSON does not respect escaped unicode characters #47353
Comments
This is unfortunate. In order to fix this, we either:
|
As an aside: it was a mistake to implement |
Would it be plausible for the JSON package to special-case This obviously doesn't scale to all types everywhere, but perhaps it would suffice for standard library types where we regret adding an |
That's another option. One detriment is that it fails to detect cases of embedding: type MyTime struct { time.Time } Here |
It also wouldn't fix it for other implementations of json (and yaml?) decoders |
I suspect YAML decoders will be fine because they will probably use the |
For what it's worth, |
Crazy idea: The This ensures backwards compatibility where EDIT: This approach assumes that either At least for |
Make it a specific sentinel error returned by |
hey @dsnet , the new way that encoding/json/v2 works allowed us to avoid this error we had. it worked wonders. Didn't see these types of bugs mentioned in the encoding/json/v2 github discussion but just so you knew that it also tackles this. |
What version of Go are you using (
go version
)?1.16.6
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?The playground.
What did you do?
Unmarshaled a JSON string containing an escaped unicode character into a
time.Time
.https://play.golang.org/p/MV6VeYcalrQ
What did you expect to see?
I expected it to parse correctly as per the JSON spec.
What did you see instead?
It did not understand the escaped character.
The text was updated successfully, but these errors were encountered: