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

cli: automatically remove a single trailing new-line character when decoding a base64 encoded input #375

Closed
leighmcculloch opened this issue Jul 12, 2024 · 1 comment · Fixed by #377
Assignees

Comments

@leighmcculloch
Copy link
Member

The CLI could automatically remove a single trailing new-line character when decoding a base64 encoded input, which would help in situations where someone has piped a base64 value and unknowingly included a new line character on the end.

This is really easy when piping the result from the echo command, which adds a new line character unless you also use the -n option. It's also really easy when piping the result from other applications that include a new line in the output at the end.

It would result in situations like this 🫨 :

❯ echo "AAAAAAAAAGQAAAAAAAAAAQAAAAAAAAAMAAAAAAAAAAAAAAABAAAAAG4cwu71zHNXx3jHCzRGOIthcnfwRgfN2f/AoHFLLMclAAAAAEySDkgAAAAAAAAAAkJVU0lORVNTAAAAAAAAAAC3JfDeo9vreItKNPoe74EkFIqWybeUQNFvLvURhHtskAAAAAAeQtHTR3+AgAAAiwkAAAAAAAAAAAAAAAA=" | stellar xdr d --type TransactionResult
{"fee_charged":100,"result":{"tx_success":[{"op_inner":{"manage_buy_offer":{"success":{"offers_claimed":[],"offer":{"updated":{"seller_id":"GBXBZQXO6XGHGV6HPDDQWNCGHCFWC4TX6BDAPTOZ77AKA4KLFTDSLROC","offer_id":1284640328,"selling":"native","buying":{"credit_alphanum12":{"asset_code":"BUSINESS","issuer":"GC3SL4G6UPN6W6ELJI2PUHXPQESBJCUWZG3ZIQGRN4XPKEMEPNWJBCRB"}},"amount":507695571,"price":{"n":1199538304,"d":35593},"flags":0,"ext":"v0"}}}}}}]},"ext":"v0"}
error: error reading file: error decoding XDR: Invalid byte 10, offset 220.
✘ exit status 1                                                                                                                                              

Becoming this 😄 :

❯ echo "AAAAAAAAAGQAAAAAAAAAAQAAAAAAAAAMAAAAAAAAAAAAAAABAAAAAG4cwu71zHNXx3jHCzRGOIthcnfwRgfN2f/AoHFLLMclAAAAAEySDkgAAAAAAAAAAkJVU0lORVNTAAAAAAAAAAC3JfDeo9vreItKNPoe74EkFIqWybeUQNFvLvURhHtskAAAAAAeQtHTR3+AgAAAiwkAAAAAAAAAAAAAAAA=" | stellar xdr d --type TransactionResult
{"fee_charged":100,"result":{"tx_success":[{"op_inner":{"manage_buy_offer":{"success":{"offers_claimed":[],"offer":{"updated":{"seller_id":"GBXBZQXO6XGHGV6HPDDQWNCGHCFWC4TX6BDAPTOZ77AKA4KLFTDSLROC","offer_id":1284640328,"selling":"native","buying":{"credit_alphanum12":{"asset_code":"BUSINESS","issuer":"GC3SL4G6UPN6W6ELJI2PUHXPQESBJCUWZG3ZIQGRN4XPKEMEPNWJBCRB"}},"amount":507695571,"price":{"n":1199538304,"d":35593},"flags":0,"ext":"v0"}}}}}}]},"ext":"v0"}
@leighmcculloch leighmcculloch self-assigned this Jul 12, 2024
@leighmcculloch
Copy link
Member Author

In general we should ignore whitespace with base64 entities since whitespace doesn't matter and sometimes folks have the base64 with hardwrap new lines within.

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 a pull request may close this issue.

1 participant