commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Julius Davies <>
Subject Re: Commons Codec: base64 "strict" mode?
Date Thu, 03 Dec 2009 21:38:18 GMT
Hi, Adam,

It doesn't currently do that.  Also, Base64 seamlessly decodes
URL_SAFE and REGULAR encodings, as well as mixes of the two, even
though a mix or URL_SAFE and REGULAR would technically be invalid.

I'm not a committer, but I could certainly put together a patch for a
strict mode.  Something like this?

1.  If character is not whitespace, and is not valid, throw exception.

2.  If character is inappropriate for our current mode (URL_SAFE or
REGULAR), throw exception.

3.  Note:  Personally I think it's too much trouble to detect weird
things like === (technically only at most == should ever exist), or
characters after ==.  What do you think?

ps.  I'd probably do it as a subclass:  Base64Strict extends Base64



On Thu, Dec 3, 2009 at 9:05 AM, Adam Rabung <> wrote:
> Hello,
> Currently, Codec skips base64 characters that are outside of the
> encode table.  I realize this is perfectly to spec, but I wonder if
> other users might appreciate a "strict" mode that throws an exception
> when one of these illegal characters are encountered.  For example, I
> would love an exception to be thrown here:
> new Base64().decode("!@#$ iHaveIllegalCharsAtBeginningAndEnd %^&"));
> My apologies if I'm missing the point or if this functionality already exists,
> Adam
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:


Julius Davies
250-592-2284 (Home)
250-893-4579 (Mobile)

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message