Merge pull request #330 from weiss/accept-newline

Accept trailing newline characters in Base64 strings
This commit is contained in:
Evgeny Khramtsov 2014-10-25 21:17:56 +04:00
commit 76b9098a25
1 changed files with 6 additions and 1 deletions

View File

@ -798,7 +798,12 @@ base64_to_term(Base64) ->
-spec decode_base64(binary()) -> binary().
decode_base64(S) ->
decode_base64_bin(S, <<>>).
case catch binary:last(S) of
C when C == $\n; C == $\s ->
decode_base64(binary:part(S, 0, byte_size(S) - 1));
_ ->
decode_base64_bin(S, <<>>)
end.
take_without_spaces(Bin, Count) ->
take_without_spaces(Bin, Count, <<>>).