rust-base64 icon indicating copy to clipboard operation
rust-base64 copied to clipboard

Successfully decode invalid input

Open hansonchar opened this issue 3 years ago • 2 comments

"djAuMC4x" is a valid base-64 encoded string whereas "djAuMC4" is not.

However, the latest v0.13.0 decodes both strings successfully when decoding the invalid one should fail.

hansonchar avatar Jul 19 '22 18:07 hansonchar

Thanks for the report; I'll look into it.

marshallpierce avatar Jul 19 '22 23:07 marshallpierce

This is related to https://github.com/marshallpierce/rust-base64/issues/182. Since padding doesn't perform any useful function, the decode logic does not currently require it.

I have some in-progress work to make padding required by default (but configurable to require no padding, or be indifferent).

marshallpierce avatar Jul 20 '22 12:07 marshallpierce

Give #198 a try and see if the error reporting works for your use case.

marshallpierce avatar Dec 01 '22 12:12 marshallpierce

Great, it works!

thread 'main' panicked at 'Failed to base 64 decode the ciphertext metadata configured due to "Invalid padding"', src/settings.rs:198:27

It failed when the invalid input "djAuMC4" is base 64 decoded vs. "djAuMC4x" which passed.

hansonchar avatar Dec 01 '22 16:12 hansonchar

Released in 0.20.0.

marshallpierce avatar Dec 10 '22 19:12 marshallpierce