base64: fixes the error message for an invalid base64 input character [backport:1.2]

This commit is contained in:
Andreas Rumpf
2020-09-20 00:05:41 +02:00
parent 9a34009f00
commit cbdda631db

View File

@@ -230,11 +230,11 @@ proc decode*(s: string): string =
template inputChar(x: untyped) =
let x = int decodeTable[ord(s[inputIndex])]
inc inputIndex
if x == invalidChar:
raise newException(ValueError,
"Invalid base64 format character `" & s[inputIndex] &
"` (ord " & $s[inputIndex].ord & ") at location " & $inputIndex & ".")
inc inputIndex
template outputChar(x: untyped) =
result[outputIndex] = char(x and 255)