[
https://issues.apache.org/jira/browse/CODEC-95?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12986951#action_12986951
]
Sebb commented on CODEC-95:
---------------------------
RFC 4648 section 3.3 says that code must reject non-alphabet characters UNLESS
the implementation specifically says otherwise.
It also says that implementations MAY state that they ignore PAD characters.
[The MIME spec relies on ignoring invalid characters to support chunked
encoding.]
So the current behaviour is OK (maybe the Javadoc needs tweaking).
We don't currently check whether input data has the correct number of octets,
so full validation is not currently directly supported.
There are possibly various different degrees of strictness:
- allow missing PAD characters
- allow PAD in data
- allow CR/LF but not other non-alphabet
- and perhaps relaxtions, e.g. Base32 might wish to treat "1" (one) as "L"
(ell).
To avoid cluttering the API unduly, how about an optional Validation object
which defines the strictness settings, and holds the location of the first
error, etc?
[I think this would only make sense for the non-chunking constructor, which
reduces the number of extra public ctors needed]
> Base64: optionally allow strict parsing of base64 strings
> ---------------------------------------------------------
>
> Key: CODEC-95
> URL: https://issues.apache.org/jira/browse/CODEC-95
> Project: Commons Codec
> Issue Type: Improvement
> Affects Versions: 1.4
> Reporter: Adam Rabung
> Priority: Minor
> Attachments: strictMode.zip
>
>
> 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 %^&"));
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.