mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-17 07:35:02 +00:00
fix(mime): use checked divisibility idiom for padding
This commit is contained in:
@@ -122,7 +122,7 @@ impl Config {
|
||||
|
||||
fn decode_inner(self, text: &[u8], optional_padding: bool) -> Result<Vec<u8>, DecodeError> {
|
||||
let (symbols, pad) = if self.padded || optional_padding {
|
||||
if !optional_padding && text.len() % 4 != 0 {
|
||||
if !optional_padding && !text.len().is_multiple_of(4) {
|
||||
return Err(DecodeError);
|
||||
}
|
||||
let pad = text.iter().rev().take(2).take_while(|c| **c == b'=').count();
|
||||
|
||||
Reference in New Issue
Block a user