Skip to content

Commit

Permalink
chore: align error for prohibited symbols after padding
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMrMilchmann committed Jan 3, 2025
1 parent 715a340 commit 3d814e2
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,12 @@ public open class Base32 private constructor(
else if (hasPadding && paddingOption == PaddingOption.ABSENT)
throw IllegalArgumentException("The padding option is set to ABSENT, but the input is padded")

require(offset >= endIndex) { "Input byte array has incorrect ending byte at $offset" }
return dstOffset - destinationOffset
if (sourceIndex < endIndex) {
val symbol = source[sourceIndex].toInt() and 0xFF
throw IllegalArgumentException("Symbol '${symbol.toChar()}'(${symbol.toString(radix = 8)}) at index ${sourceIndex - 1} is prohibited after the pad character")
}

return destinationIndex - destinationOffset
}

// `internal` for testing
Expand Down

0 comments on commit 3d814e2

Please sign in to comment.