]> granicus.if.org Git - ejabberd/commitdiff
Accept trailing whitespace in Base64 strings
authorHolger Weiss <holger@zedat.fu-berlin.de>
Sat, 25 Oct 2014 00:05:02 +0000 (02:05 +0200)
committerHolger Weiss <holger@zedat.fu-berlin.de>
Sat, 25 Oct 2014 00:05:02 +0000 (02:05 +0200)
src/jlib.erl

index 7735d7dbce32ea84e8f92ca6f3a9bce6f19843d8..be1da3fd091e05cbcd1d3f03543056281142aa6d 100644 (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, <<>>).