Skip to content

Conversation

@tsachiherman
Copy link
Contributor

@tsachiherman tsachiherman commented Jul 14, 2021

Summary

The asset parameter fields name, unit name and url might contain non-utf 8 printable characters. This PR modifies the
REST API so that the existing field would only be returned in case the entire string is a utf-8 printable string. To complement that, a _b64 version of the field would be provided, allowing the client to support non-printable strings.

Test Plan

Use existing unit tests.

@codecov-commenter
Copy link

codecov-commenter commented Jul 14, 2021

Codecov Report

Merging #2555 (94745c0) into master (01248d2) will increase coverage by 0.04%.
The diff coverage is 15.21%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2555      +/-   ##
==========================================
+ Coverage   46.89%   46.94%   +0.04%     
==========================================
  Files         346      348       +2     
  Lines       55616    55668      +52     
==========================================
+ Hits        26081    26132      +51     
- Misses      26580    26590      +10     
+ Partials     2955     2946       -9     
Impacted Files Coverage Δ
cmd/goal/account.go 14.73% <0.00%> (-0.09%) ⬇️
daemon/algod/api/server/v1/handlers/handlers.go 0.62% <0.00%> (-0.01%) ⬇️
libgoal/libgoal.go 3.05% <0.00%> (-0.14%) ⬇️
daemon/algod/api/server/v2/utils.go 14.15% <33.33%> (+0.52%) ⬆️
daemon/algod/api/server/v2/account.go 76.12% <100.00%> (+0.25%) ⬆️
libgoal/lockedFileUnix.go 0.00% <0.00%> (ø)
util/db/fullfsync_darwin.go 100.00% <0.00%> (ø)
network/wsNetwork.go 60.92% <0.00%> (+0.18%) ⬆️
ledger/eval.go 76.68% <0.00%> (+0.29%) ⬆️
ledger/acctupdates.go 62.33% <0.00%> (+0.41%) ⬆️
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 01248d2...94745c0. Read the comment docs.

UnitName: strOrNil(params.UnitName),
Url: strOrNil(params.URL),
Name: strOrNil(sanitizePrintableUTF8String(params.AssetName)),
NameB64: strOrNil(base64.StdEncoding.EncodeToString([]byte(params.AssetName))),
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we were only going to return one copy. Plain if valid, b64 otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No - we're storing one copy, but returning (sometimes) both, so that clients that use b64 could always decode that and could ignore the non-b64 version.

winder
winder previously approved these changes Jul 15, 2021
Copy link
Contributor

@winder winder left a comment

Choose a reason for hiding this comment

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

Updates LGTM

Copy link
Contributor

@algonautshant algonautshant left a comment

Choose a reason for hiding this comment

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

Looks great.

@tsachiherman tsachiherman merged commit c983ad6 into algorand:master Jul 16, 2021
@tsachiherman tsachiherman deleted the tsachi/b64assetsnames branch July 16, 2021 00:34
@tsachiherman tsachiherman restored the tsachi/b64assetsnames branch August 16, 2021 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants