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

Handle negative zero and exponential numbers in Canonical JSON verification #424

Merged
merged 5 commits into from
Dec 12, 2023

Conversation

devonh
Copy link
Contributor

@devonh devonh commented Dec 8, 2023

No description provided.

Copy link

codecov bot commented Dec 8, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (2aa5890) 58.99% compared to head (d5e13a2) 59.09%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #424      +/-   ##
==========================================
+ Coverage   58.99%   59.09%   +0.10%     
==========================================
  Files          51       51              
  Lines        7113     7124      +11     
==========================================
+ Hits         4196     4210      +14     
+ Misses       2528     2526       -2     
+ Partials      389      388       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@devonh
Copy link
Contributor Author

devonh commented Dec 8, 2023

There are commented out test cases for other invalid canonical json that we don't currently detect.
In the future we should detect them, but for now I have left them out in order to get these simple and clear violations fixed.

if got != want {
t.Errorf("CompactJSON(%q):\n want: %q\n got: %q", input, want, got)
t.Errorf("CompactJSON(%q):\n want: %q\n got: %q\n bytes: % X", input, want, got, bytes)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t.Errorf("CompactJSON(%q):\n want: %q\n got: %q\n bytes: % X", input, want, got, bytes)
t.Errorf("CompactJSON(%q):\n want: %q\n got: %q\n bytes: %x", input, want, got, bytes)

I assume? (with the recent lower-/uppercase thing?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From https://pkg.go.dev/fmt

' '	(space) leave a space for elided sign in numbers (% d);
	put spaces between bytes printing strings or slices in hex (% x, % X)

So this is fine.

@S7evinK S7evinK merged commit e97395e into main Dec 12, 2023
7 checks passed
@S7evinK S7evinK deleted the json-numbers branch December 12, 2023 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants