boris-github commented on a change in pull request #35:
URL: https://github.com/apache/commons-codec/pull/35#discussion_r571224495
##########
File path: src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
##########
@@ -223,6 +230,47 @@ protected BaseNCodec(final int unencodedBlockSize, final
int encodedBlockSize,
this.pad = pad;
}
+ /**
+ * Sets the decoding behaviour when the input bytes contain leftover
trailing bits that
+ * cannot be created by a valid encoding. These can be bits that are
unused from the final
+ * character or entire characters. The default mode is lenient decoding.
Set this to
+ * {@code true} to enable strict decoding.
+ * <ul>
+ * <li>Lenient: Any trailing bits are composed into 8-bit bytes where
possible.
+ * The remainder are discarded.
+ * <li>Strict: The decoding will raise an {@link IllegalArgumentException}
if trailing bits
+ * are not part of a valid encoding. Any unused bits from the final
character must
+ * be zero. Impossible counts of entire final characters are not
allowed.
+ * </ul>
+ *
+ * <p>When strict decoding is enabled it is expected that the decoded
bytes will be re-encoded
+ * to a byte array that matches the original, i.e. no changes occur on the
final
+ * character. This requires that the input bytes use the same padding and
alphabet
+ * as the encoder.
+ *
+ * @param strictDecoding Set to true to enable strict decoding; otherwise
use lenient decoding.
+ * @see #encode(byte[])
+ * @since 1.15
+ */
+ public void setStrictDecoding(boolean strictDecoding) {
Review comment:
Oh, I see why. Browsing the history of the file, I found that it was
modified in [Reimplement the new-in-1.15 BaseNCodec's and friends' strict vs.
lenient](https://github.com/apache/commons-codec/commit/9f1b740a17f0d54366edfb45df0636b8e302666a#diff-2cf424122556d939f7804a29ae0c501d22e744e725c1a239efd0bf687ccd7402).
Sadly the [release
notes](https://commons.apache.org/proper/commons-codec/changes-report.html#a1.15)
haven't been updated to reflect that.
(cost me 2 hours)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]