marshallpierce / rust-base64

base64, in rust
Apache License 2.0
606 stars 113 forks source link

Successfully decode invalid input #189

Closed hansonchar closed 1 year ago

hansonchar commented 2 years ago

"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.

marshallpierce commented 2 years ago

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

marshallpierce commented 2 years ago

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 commented 1 year ago

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

hansonchar commented 1 year ago

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.

marshallpierce commented 1 year ago

Released in 0.20.0.