[erlang-patches] base64:decode trailing whitespace patch for otp_src_R13B/lib/stdlib/src/base64.erl

Christopher Stelma chris@REDACTED
Mon Apr 27 16:18:26 CEST 2009


Trailing whitespace (after "=") is stripped, but the return value from
base64:strip_spaces is not in the same format expected by
base64:decode.

example of the problem:

----------------------------------------------------------------------
3> base64:decode("cXV1eA==").
<<"quux">>
4> base64:decode("cXV1eA==\n").
** exception error: no function clause matching
base64:decode([61,"=Ae1VXc"],

{-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,

-1,-1,-1,-1,-1,-1,-1,-1,...},
                                                              [])
    in function  base64:decode/1
----------------------------------------------------------------------

more specifically to the internal api:
----------------------------------------------------------------------
7> base64:strip_spaces("foo==\n", []).
[61,"=oof"]
8> base64:strip_spaces("foo==", []).
"==oof"
----------------------------------------------------------------------

patch attached.


-- 
Christopher Stelma
chris@REDACTED
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-patches/attachments/20090427/5dadf4e4/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: base64fix.diff
Type: text/x-diff
Size: 554 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-patches/attachments/20090427/5dadf4e4/attachment.bin>


More information about the erlang-patches mailing list