base64: fixes the error message for an invalid base64 input character [backport:1.2]
This commit is contained in:
parent
9a34009f00
commit
cbdda631db
1 changed files with 1 additions and 1 deletions
|
|
@ -230,11 +230,11 @@ proc decode*(s: string): string =
|
||||||
|
|
||||||
template inputChar(x: untyped) =
|
template inputChar(x: untyped) =
|
||||||
let x = int decodeTable[ord(s[inputIndex])]
|
let x = int decodeTable[ord(s[inputIndex])]
|
||||||
inc inputIndex
|
|
||||||
if x == invalidChar:
|
if x == invalidChar:
|
||||||
raise newException(ValueError,
|
raise newException(ValueError,
|
||||||
"Invalid base64 format character `" & s[inputIndex] &
|
"Invalid base64 format character `" & s[inputIndex] &
|
||||||
"` (ord " & $s[inputIndex].ord & ") at location " & $inputIndex & ".")
|
"` (ord " & $s[inputIndex].ord & ") at location " & $inputIndex & ".")
|
||||||
|
inc inputIndex
|
||||||
|
|
||||||
template outputChar(x: untyped) =
|
template outputChar(x: untyped) =
|
||||||
result[outputIndex] = char(x and 255)
|
result[outputIndex] = char(x and 255)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue