base64:mime_decode/1 should strip invalid equal signes?
satoshi kinoshita
kino@REDACTED
Fri Oct 29 04:42:20 CEST 2010
Hi,
According to the reference manual of base64 module,
I'm expecting mime_decode/1 strips "illegal characters".
It looks fine for stripping "illegal characters" for most of bad characters.
But it does not strip bad equals.
I dont' know this is a bug or not.
Invalid equal signs are not supposed to be stripped as "illegal characters"?
-------------------------------------------------------------------------------
http://www.erlang.org/doc/man/base64.html
"mime_decode/1 and mime_decode_to_string/1 strips away illegal characters,
while decode/1 and decode_to_string/1 only strips away whitespace characters."
-------------------------------------------------------------------------------
[kino@REDACTED ~] erl
Erlang R13B04 (erts-5.7.5) [source] [64-bit] [smp:2:2] [rq:2] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.7.5 (abort with ^G)
1> base64:encode("abc").
<<"YWJj">>
2> base64:mime_decode(<<"YWJj">>).
<<"abc">>
3> base64:mime_decode(<<"YWJj=">>).
** exception error: no match of right hand side value <<"abc">>
in function base64:mime_decode_binary/2
4> base64:mime_decode(<<"YWJj==">>).
** exception error: no match of right hand side value <<"abc">>
in function base64:mime_decode_binary/2
5> base64:mime_decode(<<"YW.Jj">>).
<<"abc">>
6> base64:mime_decode(<<"YW..Jj">>).
<<"abc">>
7> base64:mime_decode(<<"YW...Jj">>).
<<"abc">>
8> base64:mime_decode(<<"YW...Jj....">>).
<<"abc">>
More information about the erlang-questions
mailing list