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

Duplicate keys in JSON and fuzzing problem #31

Closed
ferretdb-bot opened this issue Nov 5, 2021 · 0 comments
Closed

Duplicate keys in JSON and fuzzing problem #31

ferretdb-bot opened this issue Nov 5, 2021 · 0 comments
Labels
code/enhancement Some user-visible feature could work better
Milestone

Comments

@ferretdb-bot
Copy link
Member

ferretdb-bot commented Nov 5, 2021

dvyukov/go-fuzz-corpus#3
golang/go#14750
golang/go#48298

Something like that might be needed in the future:

// check if j contains objects with duplicate keys that not handled by encoding/json yet:
// * https://github.com/dvyukov/go-fuzz-corpus/issues/3
// * https://github.com/golang/go/issues/14750
// * https://github.com/golang/go/issues/48298
{
	var o1 interface{}
	if err := json.Unmarshal([]byte(j), &o1); err != nil {
		t.Skip(err)
	}

	b, err := json.Marshal(o1)
	if err != nil {
		t.Skip(err)
	}

	var o2 interface{}
	if err := json.Unmarshal(b, &o2); err != nil {
		t.Skip(err)
	}

	if !reflect.DeepEqual(o1, o2) {
		t.Skip("j contains objects with duplicate keys that not handled by encoding/json yet")
	}
}
@ferretdb-bot ferretdb-bot added this to the v0.0.2 milestone Nov 12, 2021
@ferretdb-bot ferretdb-bot added the code/enhancement Some user-visible feature could work better label Nov 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code/enhancement Some user-visible feature could work better
Projects
None yet
Development

No branches or pull requests

1 participant