diff options
author | Evgeny Khramtsov <xramtsov@gmail.com> | 2014-10-25 21:17:56 +0400 |
---|---|---|
committer | Evgeny Khramtsov <xramtsov@gmail.com> | 2014-10-25 21:17:56 +0400 |
commit | 76b9098a258a92bc0756cc761c7ab314c4ebfb19 (patch) | |
tree | 3a4f54e085981141f6e6083d710aaa808fba8ae7 | |
parent | Get rid of a hyphen in VSN (diff) | |
parent | Accept trailing whitespace in Base64 strings (diff) |
Merge pull request #330 from weiss/accept-newline
Accept trailing newline characters in Base64 strings
-rw-r--r-- | src/jlib.erl | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/jlib.erl b/src/jlib.erl index 7735d7dbc..be1da3fd0 100644 --- a/src/jlib.erl +++ b/src/jlib.erl @@ -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, <<>>). |