Skip to content

Commit

Permalink
Merge pull request #143 from marshallpierce/mp/invalid-length-doc
Browse files Browse the repository at this point in the history
Add a note for InvalidLength explaining that trailing whitespace is a…
  • Loading branch information
marshallpierce authored Sep 25, 2020
2 parents 4509575 + 4547118 commit 2dc0296
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub enum DecodeError {
/// An invalid byte was found in the input. The offset and offending byte are provided.
InvalidByte(usize, u8),
/// The length of the input is invalid.
/// A typical cause of this is stray trailing whitespace or other separator bytes.
InvalidLength,
/// The last non-padding input symbol's encoded 6 bits have nonzero bits that will be discarded.
/// This is indicative of corrupted or truncated Base64.
Expand All @@ -43,7 +44,7 @@ impl fmt::Display for DecodeError {
DecodeError::InvalidByte(index, byte) => {
write!(f, "Invalid byte {}, offset {}.", byte, index)
}
DecodeError::InvalidLength => write!(f, "Encoded text cannot have a 6-bit remainder."),
DecodeError::InvalidLength => write!(f, "Encoded text cannot have a 6-bit remainder. Trailing whitespace or other bytes?"),
DecodeError::InvalidLastSymbol(index, byte) => {
write!(f, "Invalid last symbol {}, offset {}.", byte, index)
}
Expand Down

0 comments on commit 2dc0296

Please sign in to comment.