From: Holger Weiss Date: Sat, 25 Oct 2014 00:05:02 +0000 (+0200) Subject: Accept trailing whitespace in Base64 strings X-Git-Tag: 14.12~30^2^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2399aba67d2e50318f7f7cbd22af04dc2b9eadea;p=ejabberd Accept trailing whitespace in Base64 strings --- 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, <<>>).