Skip to content

xdrjson: AssetCode12 allows invalid JSON value that doesn't round trip #432

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

Open
leighmcculloch opened this issue Apr 14, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@leighmcculloch
Copy link
Member

What version are you using?

v22.1.0

What did you do?

$ echo '"ABC"' \
    | stellar xdr encode --type AssetCode12 \
    | stellar xdr decode --type AssetCode12
"ABC\\0\\0"

What did you expect to see?

Expected that the call to encode would fail, and that "ABC" would be considered an invalid AssetCode12, since that type always maps to at least 5 characters in JSON so as to clearly distinguish with AssetCode4.

The expectation is that only "ABC\\0\\0" would round trip for AssetCode12 for this value.

XDR-JSON is intended to be like XDR, that there is only a single representation for each XDR value.

What did you see instead?

The inconsistent round-tripping.

@leighmcculloch leighmcculloch added the bug Something isn't working label Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant