[
https://issues.apache.org/jira/browse/CODEC-140?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13262248#comment-13262248
]
Julius Davies commented on CODEC-140:
-------------------------------------
Consider this:
{code}
byte[] b = new byte[] { (byte) 29, (byte) -23, (byte) 101, (byte) -93 };
System.out.println(Base64.encodeBase64URLSafeString(b));
{code}
It prints "Hellow" on the console. So it makes sense for
Base64.isBase64("Hellow") to return true.
As for "Hello"... isBase64() just cares that the characters are in the base64
alphabet. Turns out it is impossible, though, to encode any binary sequence
such that a 5-character encoding is created, since that would correspond to a
30 bit sequence. The final 6 bits of encoding (the 5th character) would always
get discarded during the decode().
So maybe one could make a case that isBase64("Hello") should return false
because of the 5th character being meaningless, but so far that hasn't been our
approach.
> isBase64 returns true for any UTF8 string
> -----------------------------------------
>
> Key: CODEC-140
> URL: https://issues.apache.org/jira/browse/CODEC-140
> Project: Commons Codec
> Issue Type: Bug
> Affects Versions: 1.6
> Environment: windows/linux
> Reporter: Mohit Anchlia
> Assignee: Julius Davies
>
> I just called Base64.isBase64("Hello") for instance and it returns true. I
> thought it would return true only if it is valid base64 encoded string.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira