Skip to content

Commit

Permalink
Update base64 behavior on wrong length
Browse files Browse the repository at this point in the history
  • Loading branch information
ia0 committed Dec 17, 2022
1 parent 61a5240 commit e2a9d99
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cmp/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ fn difference() {
assert_eq!(base64::decode(x).err().unwrap(), InvalidLength);
let x = b"AAB";
assert_eq!(BASE64.decode(x).err().unwrap(), DecodeError { position: 0, kind: Length });
assert_eq!(base64::decode(x).err().unwrap(), InvalidLastSymbol(2, b'B'));
assert_eq!(base64::decode(x).err().unwrap(), InvalidPadding);
let x = b"AAA";
assert_eq!(BASE64.decode(x).err().unwrap(), DecodeError { position: 0, kind: Length });
assert_eq!(base64::decode(x).unwrap(), vec![0, 0]);
assert_eq!(base64::decode(x).err().unwrap(), InvalidPadding);
let x = b"A\rA\nB=";
assert_eq!(BASE64.decode(x).err().unwrap(), DecodeError { position: 4, kind: Length });
assert_eq!(base64::decode(x).err().unwrap(), InvalidByte(1, b'\r'));
Expand Down
4 changes: 2 additions & 2 deletions lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@
//! | ---------- | --------------- | --------- | ------------- |
//! | `AAB=` | `Trailing(2)` | `Last(2)` | `\x00\x00` |
//! | `AA\nB=` | `Length(4)` | `Length` | `\x00\x00` |
//! | `AAB` | `Length(0)` | `Last(2)` | Invalid input |
//! | `AAA` | `Length(0)` | `[0, 0]` | Invalid input |
//! | `AAB` | `Length(0)` | `Padding` | Invalid input |
//! | `AAA` | `Length(0)` | `Padding` | Invalid input |
//! | `A\rA\nB=` | `Length(4)` | `Byte(1)` | Invalid input |
//! | `-_\r\n` | `Symbol(0)` | `Byte(0)` | Invalid input |
//! | `AA==AA==` | `[0, 0]` | `Byte(2)` | `\x00\x00` |
Expand Down

0 comments on commit e2a9d99

Please sign in to comment.