Modified: websites/production/commons/content/proper/commons-codec/jacoco/org.apache.commons.codec.binary/Base32.java.html ============================================================================== --- websites/production/commons/content/proper/commons-codec/jacoco/org.apache.commons.codec.binary/Base32.java.html (original) +++ websites/production/commons/content/proper/commons-codec/jacoco/org.apache.commons.codec.binary/Base32.java.html Mon Jan 27 18:12:24 2025 @@ -75,6 +75,33 @@ public class Base32 extends BaseNCodec { <span class="fc" id="L75"> return new Base32(getLineLength(), getLineSeparator(), getEncodeTable(), getPadding(), getDecodingPolicy());</span> } + /** + * Sets the decode table to use Base32 hexadecimal if {@code true}, otherwise use the Base32 alphabet. + * <p> + * This overrides a value previously set with {@link #setEncodeTable(byte...)}. + * </p> + * + * @param useHex use Base32 hexadecimal if {@code true}, otherwise use the Base32 alphabet. + * @return this instance. + * @since 1.18.0 + */ + public Builder setHexDecodeTable(final boolean useHex) { +<span class="fc" id="L89"> return setEncodeTable(decodeTable(useHex));</span> + } + + /** + * Sets the encode table to use Base32 hexadecimal if {@code true}, otherwise use the Base32 alphabet. + * <p> + * This overrides a value previously set with {@link #setEncodeTable(byte...)}. + * </p> + * + * @param useHex use Base32 hexadecimal if {@code true}, otherwise use the Base32 alphabet. + * @return this instance. + * @since 1.18.0 + */ + public Builder setHexEncodeTable(final boolean useHex) { +<span class="fc" id="L103"> return setEncodeTable(encodeTable(useHex));</span> + } } /** @@ -90,7 +117,7 @@ public class Base32 extends BaseNCodec { * positive integer equivalents. Characters that are not in the Base32 alphabet but fall within the bounds of the array are translated to -1. */ // @formatter:off -<span class="fc" id="L93"> private static final byte[] DECODE_TABLE = {</span> +<span class="fc" id="L120"> private static final byte[] DECODE_TABLE = {</span> // 0 1 2 3 4 5 6 7 8 9 A B C D E F -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 00-0f -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 10-1f @@ -109,7 +136,7 @@ public class Base32 extends BaseNCodec { * 4648. */ // @formatter:off -<span class="fc" id="L112"> private static final byte[] ENCODE_TABLE = {</span> +<span class="fc" id="L139"> private static final byte[] ENCODE_TABLE = {</span> 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '2', '3', '4', '5', '6', '7', @@ -121,7 +148,7 @@ public class Base32 extends BaseNCodec { * 5-bit positive integer equivalents. Characters that are not in the Base32 Hex alphabet but fall within the bounds of the array are translated to -1. */ // @formatter:off -<span class="fc" id="L124"> private static final byte[] HEX_DECODE_TABLE = {</span> +<span class="fc" id="L151"> private static final byte[] HEX_DECODE_TABLE = {</span> // 0 1 2 3 4 5 6 7 8 9 A B C D E F -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 00-0f -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 10-1f @@ -140,7 +167,7 @@ public class Base32 extends BaseNCodec { * RFC 4648. */ // @formatter:off -<span class="fc" id="L143"> private static final byte[] HEX_ENCODE_TABLE = {</span> +<span class="fc" id="L170"> private static final byte[] HEX_ENCODE_TABLE = {</span> '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', @@ -162,6 +189,10 @@ public class Base32 extends BaseNCodec { /** Mask used to extract 1 bits, used when decoding final trailing character. */ private static final long MASK_1BITS = 0x01L; + // The static final fields above are used for the original static byte[] methods on Base32. + // The private member fields below are used with the new streaming approach, which requires + // some state be preserved between calls of encode() and decode(). + /** * Creates a new Builder. * @@ -169,12 +200,16 @@ public class Base32 extends BaseNCodec { * @since 1.17.0 */ public static Builder builder() { -<span class="fc" id="L172"> return new Builder();</span> +<span class="fc" id="L203"> return new Builder();</span> } - // The static final fields above are used for the original static byte[] methods on Base32. - // The private member fields below are used with the new streaming approach, which requires - // some state be preserved between calls of encode() and decode(). + private static byte[] decodeTable(final boolean useHex) { +<span class="fc bfc" id="L207" title="All 2 branches covered."> return useHex ? HEX_DECODE_TABLE : DECODE_TABLE;</span> + } + + private static byte[] encodeTable(final boolean useHex) { +<span class="fc bfc" id="L211" title="All 2 branches covered."> return useHex ? HEX_ENCODE_TABLE : ENCODE_TABLE;</span> + } /** * Decode table to use. @@ -204,8 +239,8 @@ public class Base32 extends BaseNCodec { * </p> */ public Base32() { -<span class="fc" id="L207"> this(false);</span> -<span class="fc" id="L208"> }</span> +<span class="fc" id="L242"> this(false);</span> +<span class="fc" id="L243"> }</span> /** * Constructs a Base32 codec used for decoding and encoding. @@ -216,8 +251,8 @@ public class Base32 extends BaseNCodec { * @param useHex if {@code true} then use Base32 Hex alphabet */ public Base32(final boolean useHex) { -<span class="fc" id="L219"> this(0, null, useHex, PAD_DEFAULT);</span> -<span class="fc" id="L220"> }</span> +<span class="fc" id="L254"> this(0, null, useHex, PAD_DEFAULT);</span> +<span class="fc" id="L255"> }</span> /** * Constructs a Base32 codec used for decoding and encoding. @@ -229,8 +264,8 @@ public class Base32 extends BaseNCodec { * @param padding byte used as padding byte. */ public Base32(final boolean useHex, final byte padding) { -<span class="fc" id="L232"> this(0, null, useHex, padding);</span> -<span class="fc" id="L233"> }</span> +<span class="fc" id="L267"> this(0, null, useHex, padding);</span> +<span class="fc" id="L268"> }</span> /** * Constructs a Base32 codec used for decoding and encoding. @@ -241,8 +276,8 @@ public class Base32 extends BaseNCodec { * @param pad byte used as padding byte. */ public Base32(final byte pad) { -<span class="fc" id="L244"> this(false, pad);</span> -<span class="fc" id="L245"> }</span> +<span class="fc" id="L279"> this(false, pad);</span> +<span class="fc" id="L280"> }</span> /** * Constructs a Base32 codec used for decoding and encoding. @@ -254,8 +289,8 @@ public class Base32 extends BaseNCodec { * the output will not be divided into lines (chunks). Ignored when decoding. */ public Base32(final int lineLength) { -<span class="fc" id="L257"> this(lineLength, CHUNK_SEPARATOR);</span> -<span class="fc" id="L258"> }</span> +<span class="fc" id="L292"> this(lineLength, CHUNK_SEPARATOR);</span> +<span class="fc" id="L293"> }</span> /** * Constructs a Base32 codec used for decoding and encoding. @@ -272,8 +307,8 @@ public class Base32 extends BaseNCodec { * @throws IllegalArgumentException Thrown when the {@code lineSeparator} contains Base32 characters. */ public Base32(final int lineLength, final byte[] lineSeparator) { -<span class="fc" id="L275"> this(lineLength, lineSeparator, false, PAD_DEFAULT);</span> -<span class="fc" id="L276"> }</span> +<span class="fc" id="L310"> this(lineLength, lineSeparator, false, PAD_DEFAULT);</span> +<span class="fc" id="L311"> }</span> /** * Constructs a Base32 / Base32 Hex codec used for decoding and encoding. @@ -291,8 +326,8 @@ public class Base32 extends BaseNCodec { * @throws IllegalArgumentException Thrown when the {@code lineSeparator} contains Base32 characters. Or the lineLength &gt; 0 and lineSeparator is null. */ public Base32(final int lineLength, final byte[] lineSeparator, final boolean useHex) { -<span class="fc" id="L294"> this(lineLength, lineSeparator, useHex, PAD_DEFAULT);</span> -<span class="fc" id="L295"> }</span> +<span class="fc" id="L329"> this(lineLength, lineSeparator, useHex, PAD_DEFAULT);</span> +<span class="fc" id="L330"> }</span> /** * Constructs a Base32 / Base32 Hex codec used for decoding and encoding. @@ -311,8 +346,8 @@ public class Base32 extends BaseNCodec { * @throws IllegalArgumentException Thrown when the {@code lineSeparator} contains Base32 characters. Or the lineLength &gt; 0 and lineSeparator is null. */ public Base32(final int lineLength, final byte[] lineSeparator, final boolean useHex, final byte padding) { -<span class="fc" id="L314"> this(lineLength, lineSeparator, useHex, padding, DECODING_POLICY_DEFAULT);</span> -<span class="fc" id="L315"> }</span> +<span class="fc" id="L349"> this(lineLength, lineSeparator, useHex, padding, DECODING_POLICY_DEFAULT);</span> +<span class="fc" id="L350"> }</span> /** * Constructs a Base32 / Base32 Hex codec used for decoding and encoding. @@ -326,15 +361,15 @@ public class Base32 extends BaseNCodec { * @param lineLength Each line of encoded data will be at most of the given length (rounded down to the nearest multiple of 8). If lineLength &lt;= 0, * then the output will not be divided into lines (chunks). Ignored when decoding. * @param lineSeparator Each line of encoded data will end with this sequence of bytes. - * @param useHex if {@code true}, then use Base32 Hex alphabet, otherwise use Base32 alphabet + * @param useHex use Base32 hexadecimal if {@code true}, otherwise use the Base32 alphabet. * @param padding padding byte. * @param decodingPolicy The decoding policy. * @throws IllegalArgumentException Thrown when the {@code lineSeparator} contains Base32 characters. Or the lineLength &gt; 0 and lineSeparator is null. * @since 1.15 */ public Base32(final int lineLength, final byte[] lineSeparator, final boolean useHex, final byte padding, final CodecPolicy decodingPolicy) { -<span class="fc bfc" id="L336" title="All 2 branches covered."> this(lineLength, lineSeparator, useHex ? HEX_ENCODE_TABLE : ENCODE_TABLE, padding, decodingPolicy);</span> -<span class="fc" id="L337"> }</span> +<span class="fc" id="L371"> this(lineLength, lineSeparator, encodeTable(useHex), padding, decodingPolicy);</span> +<span class="fc" id="L372"> }</span> /** * Constructs a Base32 / Base32 Hex codec used for decoding and encoding. @@ -354,30 +389,30 @@ public class Base32 extends BaseNCodec { * @throws IllegalArgumentException Thrown when the {@code lineSeparator} contains Base32 characters. Or the lineLength &gt; 0 and lineSeparator is null. */ private Base32(final int lineLength, final byte[] lineSeparator, final byte[] encodeTable, final byte padding, final CodecPolicy decodingPolicy) { -<span class="fc" id="L357"> super(BYTES_PER_UNENCODED_BLOCK, BYTES_PER_ENCODED_BLOCK, lineLength, toLength(lineSeparator), padding, decodingPolicy);</span> -<span class="fc" id="L358"> Objects.requireNonNull(encodeTable, "encodeTable");</span> -<span class="fc" id="L359"> this.encodeTable = encodeTable;</span> -<span class="fc bfc" id="L360" title="All 2 branches covered."> this.decodeTable = encodeTable == HEX_ENCODE_TABLE ? HEX_DECODE_TABLE : DECODE_TABLE;</span> -<span class="fc bfc" id="L361" title="All 2 branches covered."> if (lineLength > 0) {</span> -<span class="fc bfc" id="L362" title="All 2 branches covered."> if (lineSeparator == null) {</span> -<span class="fc" id="L363"> throw new IllegalArgumentException("lineLength " + lineLength + " > 0, but lineSeparator is null");</span> +<span class="fc" id="L392"> super(BYTES_PER_UNENCODED_BLOCK, BYTES_PER_ENCODED_BLOCK, lineLength, toLength(lineSeparator), padding, decodingPolicy);</span> +<span class="fc" id="L393"> Objects.requireNonNull(encodeTable, "encodeTable");</span> +<span class="fc" id="L394"> this.encodeTable = encodeTable;</span> +<span class="fc bfc" id="L395" title="All 2 branches covered."> this.decodeTable = encodeTable == HEX_ENCODE_TABLE ? HEX_DECODE_TABLE : DECODE_TABLE;</span> +<span class="fc bfc" id="L396" title="All 2 branches covered."> if (lineLength > 0) {</span> +<span class="fc bfc" id="L397" title="All 2 branches covered."> if (lineSeparator == null) {</span> +<span class="fc" id="L398"> throw new IllegalArgumentException("lineLength " + lineLength + " > 0, but lineSeparator is null");</span> } -<span class="fc" id="L365"> final byte[] lineSeparatorCopy = lineSeparator.clone();</span> +<span class="fc" id="L400"> final byte[] lineSeparatorCopy = lineSeparator.clone();</span> // Must be done after initializing the tables -<span class="fc bfc" id="L367" title="All 2 branches covered."> if (containsAlphabetOrPad(lineSeparatorCopy)) {</span> -<span class="fc" id="L368"> final String sep = StringUtils.newStringUtf8(lineSeparatorCopy);</span> -<span class="fc" id="L369"> throw new IllegalArgumentException("lineSeparator must not contain Base32 characters: [" + sep + "]");</span> +<span class="fc bfc" id="L402" title="All 2 branches covered."> if (containsAlphabetOrPad(lineSeparatorCopy)) {</span> +<span class="fc" id="L403"> final String sep = StringUtils.newStringUtf8(lineSeparatorCopy);</span> +<span class="fc" id="L404"> throw new IllegalArgumentException("lineSeparator must not contain Base32 characters: [" + sep + "]");</span> } -<span class="fc" id="L371"> this.encodeSize = BYTES_PER_ENCODED_BLOCK + lineSeparatorCopy.length;</span> -<span class="fc" id="L372"> this.lineSeparator = lineSeparatorCopy;</span> -<span class="fc" id="L373"> } else {</span> -<span class="fc" id="L374"> this.encodeSize = BYTES_PER_ENCODED_BLOCK;</span> -<span class="fc" id="L375"> this.lineSeparator = null;</span> +<span class="fc" id="L406"> this.encodeSize = BYTES_PER_ENCODED_BLOCK + lineSeparatorCopy.length;</span> +<span class="fc" id="L407"> this.lineSeparator = lineSeparatorCopy;</span> +<span class="fc" id="L408"> } else {</span> +<span class="fc" id="L409"> this.encodeSize = BYTES_PER_ENCODED_BLOCK;</span> +<span class="fc" id="L410"> this.lineSeparator = null;</span> } -<span class="fc bfc" id="L377" title="All 4 branches covered."> if (isInAlphabet(padding) || Character.isWhitespace(padding)) {</span> -<span class="fc" id="L378"> throw new IllegalArgumentException("pad must not be in alphabet or whitespace");</span> +<span class="fc bfc" id="L412" title="All 4 branches covered."> if (isInAlphabet(padding) || Character.isWhitespace(padding)) {</span> +<span class="fc" id="L413"> throw new IllegalArgumentException("pad must not be in alphabet or whitespace");</span> } -<span class="fc" id="L380"> }</span> +<span class="fc" id="L415"> }</span> /** * <p> @@ -385,7 +420,7 @@ public class Base32 extends BaseNCodec { * inAvail set to "-1" to alert decoder that EOF has been reached. The "-1" call is not necessary when decoding, but it doesn't hurt, either. * </p> * <p> - * Ignores all non-Base32 characters. This is how chunked (e.g. 76 character) data is handled, since CR and LF are silently ignored, but has implications + * Ignores all non-Base32 characters. This is how chunked (for example 76 character) data is handled, since CR and LF are silently ignored, but has implications * for other bytes, too. This method subscribes to the garbage-in, garbage-out philosophy: it will not check the provided data for validity. * </p> * <p> @@ -401,33 +436,33 @@ public class Base32 extends BaseNCodec { @Override void decode(final byte[] input, int inPos, final int inAvail, final Context context) { // package protected for access from I/O streams -<span class="fc bfc" id="L404" title="All 2 branches covered."> if (context.eof) {</span> -<span class="fc" id="L405"> return;</span> +<span class="fc bfc" id="L439" title="All 2 branches covered."> if (context.eof) {</span> +<span class="fc" id="L440"> return;</span> } -<span class="fc bfc" id="L407" title="All 2 branches covered."> if (inAvail < 0) {</span> -<span class="fc" id="L408"> context.eof = true;</span> +<span class="fc bfc" id="L442" title="All 2 branches covered."> if (inAvail < 0) {</span> +<span class="fc" id="L443"> context.eof = true;</span> } -<span class="fc" id="L410"> final int decodeSize = this.encodeSize - 1;</span> -<span class="fc bfc" id="L411" title="All 2 branches covered."> for (int i = 0; i < inAvail; i++) {</span> -<span class="fc" id="L412"> final byte b = input[inPos++];</span> -<span class="fc bfc" id="L413" title="All 2 branches covered."> if (b == pad) {</span> +<span class="fc" id="L445"> final int decodeSize = this.encodeSize - 1;</span> +<span class="fc bfc" id="L446" title="All 2 branches covered."> for (int i = 0; i < inAvail; i++) {</span> +<span class="fc" id="L447"> final byte b = input[inPos++];</span> +<span class="fc bfc" id="L448" title="All 2 branches covered."> if (b == pad) {</span> // We're done. -<span class="fc" id="L415"> context.eof = true;</span> -<span class="fc" id="L416"> break;</span> +<span class="fc" id="L450"> context.eof = true;</span> +<span class="fc" id="L451"> break;</span> } -<span class="fc" id="L418"> final byte[] buffer = ensureBufferSize(decodeSize, context);</span> -<span class="pc bpc" id="L419" title="2 of 4 branches missed."> if (b >= 0 && b < this.decodeTable.length) {</span> -<span class="fc" id="L420"> final int result = this.decodeTable[b];</span> -<span class="fc bfc" id="L421" title="All 2 branches covered."> if (result >= 0) {</span> -<span class="fc" id="L422"> context.modulus = (context.modulus + 1) % BYTES_PER_ENCODED_BLOCK;</span> +<span class="fc" id="L453"> final byte[] buffer = ensureBufferSize(decodeSize, context);</span> +<span class="pc bpc" id="L454" title="2 of 4 branches missed."> if (b >= 0 && b < this.decodeTable.length) {</span> +<span class="fc" id="L455"> final int result = this.decodeTable[b];</span> +<span class="fc bfc" id="L456" title="All 2 branches covered."> if (result >= 0) {</span> +<span class="fc" id="L457"> context.modulus = (context.modulus + 1) % BYTES_PER_ENCODED_BLOCK;</span> // collect decoded bytes -<span class="fc" id="L424"> context.lbitWorkArea = (context.lbitWorkArea << BITS_PER_ENCODED_BYTE) + result;</span> -<span class="fc bfc" id="L425" title="All 2 branches covered."> if (context.modulus == 0) { // we can output the 5 bytes</span> -<span class="fc" id="L426"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 32 & MASK_8BITS);</span> -<span class="fc" id="L427"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 24 & MASK_8BITS);</span> -<span class="fc" id="L428"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 16 & MASK_8BITS);</span> -<span class="fc" id="L429"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 8 & MASK_8BITS);</span> -<span class="fc" id="L430"> buffer[context.pos++] = (byte) (context.lbitWorkArea & MASK_8BITS);</span> +<span class="fc" id="L459"> context.lbitWorkArea = (context.lbitWorkArea << BITS_PER_ENCODED_BYTE) + result;</span> +<span class="fc bfc" id="L460" title="All 2 branches covered."> if (context.modulus == 0) { // we can output the 5 bytes</span> +<span class="fc" id="L461"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 32 & MASK_8BITS);</span> +<span class="fc" id="L462"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 24 & MASK_8BITS);</span> +<span class="fc" id="L463"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 16 & MASK_8BITS);</span> +<span class="fc" id="L464"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 8 & MASK_8BITS);</span> +<span class="fc" id="L465"> buffer[context.pos++] = (byte) (context.lbitWorkArea & MASK_8BITS);</span> } } } @@ -435,62 +470,62 @@ public class Base32 extends BaseNCodec { // Two forms of EOF as far as Base32 decoder is concerned: actual // EOF (-1) and first time '=' character is encountered in stream. // This approach makes the '=' padding characters completely optional. -<span class="fc bfc" id="L438" title="All 4 branches covered."> if (context.eof && context.modulus > 0) { // if modulus == 0, nothing to do</span> -<span class="fc" id="L439"> final byte[] buffer = ensureBufferSize(decodeSize, context);</span> +<span class="fc bfc" id="L473" title="All 4 branches covered."> if (context.eof && context.modulus > 0) { // if modulus == 0, nothing to do</span> +<span class="fc" id="L474"> final byte[] buffer = ensureBufferSize(decodeSize, context);</span> // We ignore partial bytes, i.e. only multiples of 8 count. // Any combination not part of a valid encoding is either partially decoded // or will raise an exception. Possible trailing characters are 2, 4, 5, 7. // It is not possible to encode with 1, 3, 6 trailing characters. // For backwards compatibility 3 & 6 chars are decoded anyway rather than discarded. // See the encode(byte[]) method EOF section. -<span class="pc bpc" id="L446" title="1 of 8 branches missed."> switch (context.modulus) {</span> +<span class="pc bpc" id="L481" title="1 of 8 branches missed."> switch (context.modulus) {</span> // case 0 : // impossible, as excluded above case 1: // 5 bits - either ignore entirely, or raise an exception -<span class="fc" id="L449"> validateTrailingCharacters();</span> +<span class="fc" id="L484"> validateTrailingCharacters();</span> case 2: // 10 bits, drop 2 and output one byte -<span class="fc" id="L451"> validateCharacter(MASK_2BITS, context);</span> -<span class="fc" id="L452"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 2 & MASK_8BITS);</span> -<span class="fc" id="L453"> break;</span> +<span class="fc" id="L486"> validateCharacter(MASK_2BITS, context);</span> +<span class="fc" id="L487"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 2 & MASK_8BITS);</span> +<span class="fc" id="L488"> break;</span> case 3: // 15 bits, drop 7 and output 1 byte, or raise an exception -<span class="fc" id="L455"> validateTrailingCharacters();</span> +<span class="fc" id="L490"> validateTrailingCharacters();</span> // Not possible from a valid encoding but decode anyway -<span class="fc" id="L457"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 7 & MASK_8BITS);</span> -<span class="fc" id="L458"> break;</span> +<span class="fc" id="L492"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 7 & MASK_8BITS);</span> +<span class="fc" id="L493"> break;</span> case 4: // 20 bits = 2*8 + 4 -<span class="fc" id="L460"> validateCharacter(MASK_4BITS, context);</span> -<span class="fc" id="L461"> context.lbitWorkArea = context.lbitWorkArea >> 4; // drop 4 bits</span> -<span class="fc" id="L462"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 8 & MASK_8BITS);</span> -<span class="fc" id="L463"> buffer[context.pos++] = (byte) (context.lbitWorkArea & MASK_8BITS);</span> -<span class="fc" id="L464"> break;</span> +<span class="fc" id="L495"> validateCharacter(MASK_4BITS, context);</span> +<span class="fc" id="L496"> context.lbitWorkArea = context.lbitWorkArea >> 4; // drop 4 bits</span> +<span class="fc" id="L497"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 8 & MASK_8BITS);</span> +<span class="fc" id="L498"> buffer[context.pos++] = (byte) (context.lbitWorkArea & MASK_8BITS);</span> +<span class="fc" id="L499"> break;</span> case 5: // 25 bits = 3*8 + 1 -<span class="fc" id="L466"> validateCharacter(MASK_1BITS, context);</span> -<span class="fc" id="L467"> context.lbitWorkArea = context.lbitWorkArea >> 1;</span> -<span class="fc" id="L468"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 16 & MASK_8BITS);</span> -<span class="fc" id="L469"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 8 & MASK_8BITS);</span> -<span class="fc" id="L470"> buffer[context.pos++] = (byte) (context.lbitWorkArea & MASK_8BITS);</span> -<span class="fc" id="L471"> break;</span> +<span class="fc" id="L501"> validateCharacter(MASK_1BITS, context);</span> +<span class="fc" id="L502"> context.lbitWorkArea = context.lbitWorkArea >> 1;</span> +<span class="fc" id="L503"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 16 & MASK_8BITS);</span> +<span class="fc" id="L504"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 8 & MASK_8BITS);</span> +<span class="fc" id="L505"> buffer[context.pos++] = (byte) (context.lbitWorkArea & MASK_8BITS);</span> +<span class="fc" id="L506"> break;</span> case 6: // 30 bits = 3*8 + 6, or raise an exception -<span class="fc" id="L473"> validateTrailingCharacters();</span> +<span class="fc" id="L508"> validateTrailingCharacters();</span> // Not possible from a valid encoding but decode anyway -<span class="fc" id="L475"> context.lbitWorkArea = context.lbitWorkArea >> 6;</span> -<span class="fc" id="L476"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 16 & MASK_8BITS);</span> -<span class="fc" id="L477"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 8 & MASK_8BITS);</span> -<span class="fc" id="L478"> buffer[context.pos++] = (byte) (context.lbitWorkArea & MASK_8BITS);</span> -<span class="fc" id="L479"> break;</span> +<span class="fc" id="L510"> context.lbitWorkArea = context.lbitWorkArea >> 6;</span> +<span class="fc" id="L511"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 16 & MASK_8BITS);</span> +<span class="fc" id="L512"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 8 & MASK_8BITS);</span> +<span class="fc" id="L513"> buffer[context.pos++] = (byte) (context.lbitWorkArea & MASK_8BITS);</span> +<span class="fc" id="L514"> break;</span> case 7: // 35 bits = 4*8 +3 -<span class="fc" id="L481"> validateCharacter(MASK_3BITS, context);</span> -<span class="fc" id="L482"> context.lbitWorkArea = context.lbitWorkArea >> 3;</span> -<span class="fc" id="L483"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 24 & MASK_8BITS);</span> -<span class="fc" id="L484"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 16 & MASK_8BITS);</span> -<span class="fc" id="L485"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 8 & MASK_8BITS);</span> -<span class="fc" id="L486"> buffer[context.pos++] = (byte) (context.lbitWorkArea & MASK_8BITS);</span> -<span class="fc" id="L487"> break;</span> +<span class="fc" id="L516"> validateCharacter(MASK_3BITS, context);</span> +<span class="fc" id="L517"> context.lbitWorkArea = context.lbitWorkArea >> 3;</span> +<span class="fc" id="L518"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 24 & MASK_8BITS);</span> +<span class="fc" id="L519"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 16 & MASK_8BITS);</span> +<span class="fc" id="L520"> buffer[context.pos++] = (byte) (context.lbitWorkArea >> 8 & MASK_8BITS);</span> +<span class="fc" id="L521"> buffer[context.pos++] = (byte) (context.lbitWorkArea & MASK_8BITS);</span> +<span class="fc" id="L522"> break;</span> default: // modulus can be 0-7, and we excluded 0,1 already -<span class="nc" id="L490"> throw new IllegalStateException("Impossible modulus " + context.modulus);</span> +<span class="nc" id="L525"> throw new IllegalStateException("Impossible modulus " + context.modulus);</span> } } -<span class="fc" id="L493"> }</span> +<span class="fc" id="L528"> }</span> /** * <p> @@ -506,98 +541,98 @@ public class Base32 extends BaseNCodec { @Override void encode(final byte[] input, int inPos, final int inAvail, final Context context) { // package protected for access from I/O streams -<span class="fc bfc" id="L509" title="All 2 branches covered."> if (context.eof) {</span> -<span class="fc" id="L510"> return;</span> +<span class="fc bfc" id="L544" title="All 2 branches covered."> if (context.eof) {</span> +<span class="fc" id="L545"> return;</span> } // inAvail < 0 is how we're informed of EOF in the underlying data we're // encoding. -<span class="fc bfc" id="L514" title="All 2 branches covered."> if (inAvail < 0) {</span> -<span class="fc" id="L515"> context.eof = true;</span> -<span class="fc bfc" id="L516" title="All 4 branches covered."> if (0 == context.modulus && lineLength == 0) {</span> -<span class="fc" id="L517"> return; // no leftovers to process and not using chunking</span> +<span class="fc bfc" id="L549" title="All 2 branches covered."> if (inAvail < 0) {</span> +<span class="fc" id="L550"> context.eof = true;</span> +<span class="fc bfc" id="L551" title="All 4 branches covered."> if (0 == context.modulus && lineLength == 0) {</span> +<span class="fc" id="L552"> return; // no leftovers to process and not using chunking</span> } -<span class="fc" id="L519"> final byte[] buffer = ensureBufferSize(encodeSize, context);</span> -<span class="fc" id="L520"> final int savedPos = context.pos;</span> -<span class="pc bpc" id="L521" title="1 of 6 branches missed."> switch (context.modulus) { // % 5</span> +<span class="fc" id="L554"> final byte[] buffer = ensureBufferSize(encodeSize, context);</span> +<span class="fc" id="L555"> final int savedPos = context.pos;</span> +<span class="pc bpc" id="L556" title="1 of 6 branches missed."> switch (context.modulus) { // % 5</span> case 0: -<span class="fc" id="L523"> break;</span> +<span class="fc" id="L558"> break;</span> case 1: // Only 1 octet; take top 5 bits then remainder -<span class="fc" id="L525"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 3) & MASK_5BITS]; // 8-1*5 = 3</span> -<span class="fc" id="L526"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea << 2) & MASK_5BITS]; // 5-3=2</span> -<span class="fc" id="L527"> buffer[context.pos++] = pad;</span> -<span class="fc" id="L528"> buffer[context.pos++] = pad;</span> -<span class="fc" id="L529"> buffer[context.pos++] = pad;</span> -<span class="fc" id="L530"> buffer[context.pos++] = pad;</span> -<span class="fc" id="L531"> buffer[context.pos++] = pad;</span> -<span class="fc" id="L532"> buffer[context.pos++] = pad;</span> -<span class="fc" id="L533"> break;</span> +<span class="fc" id="L560"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 3) & MASK_5BITS]; // 8-1*5 = 3</span> +<span class="fc" id="L561"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea << 2) & MASK_5BITS]; // 5-3=2</span> +<span class="fc" id="L562"> buffer[context.pos++] = pad;</span> +<span class="fc" id="L563"> buffer[context.pos++] = pad;</span> +<span class="fc" id="L564"> buffer[context.pos++] = pad;</span> +<span class="fc" id="L565"> buffer[context.pos++] = pad;</span> +<span class="fc" id="L566"> buffer[context.pos++] = pad;</span> +<span class="fc" id="L567"> buffer[context.pos++] = pad;</span> +<span class="fc" id="L568"> break;</span> case 2: // 2 octets = 16 bits to use -<span class="fc" id="L535"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 11) & MASK_5BITS]; // 16-1*5 = 11</span> -<span class="fc" id="L536"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 6) & MASK_5BITS]; // 16-2*5 = 6</span> -<span class="fc" id="L537"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 1) & MASK_5BITS]; // 16-3*5 = 1</span> -<span class="fc" id="L538"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea << 4) & MASK_5BITS]; // 5-1 = 4</span> -<span class="fc" id="L539"> buffer[context.pos++] = pad;</span> -<span class="fc" id="L540"> buffer[context.pos++] = pad;</span> -<span class="fc" id="L541"> buffer[context.pos++] = pad;</span> -<span class="fc" id="L542"> buffer[context.pos++] = pad;</span> -<span class="fc" id="L543"> break;</span> +<span class="fc" id="L570"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 11) & MASK_5BITS]; // 16-1*5 = 11</span> +<span class="fc" id="L571"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 6) & MASK_5BITS]; // 16-2*5 = 6</span> +<span class="fc" id="L572"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 1) & MASK_5BITS]; // 16-3*5 = 1</span> +<span class="fc" id="L573"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea << 4) & MASK_5BITS]; // 5-1 = 4</span> +<span class="fc" id="L574"> buffer[context.pos++] = pad;</span> +<span class="fc" id="L575"> buffer[context.pos++] = pad;</span> +<span class="fc" id="L576"> buffer[context.pos++] = pad;</span> +<span class="fc" id="L577"> buffer[context.pos++] = pad;</span> +<span class="fc" id="L578"> break;</span> case 3: // 3 octets = 24 bits to use -<span class="fc" id="L545"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 19) & MASK_5BITS]; // 24-1*5 = 19</span> -<span class="fc" id="L546"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 14) & MASK_5BITS]; // 24-2*5 = 14</span> -<span class="fc" id="L547"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 9) & MASK_5BITS]; // 24-3*5 = 9</span> -<span class="fc" id="L548"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 4) & MASK_5BITS]; // 24-4*5 = 4</span> -<span class="fc" id="L549"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea << 1) & MASK_5BITS]; // 5-4 = 1</span> -<span class="fc" id="L550"> buffer[context.pos++] = pad;</span> -<span class="fc" id="L551"> buffer[context.pos++] = pad;</span> -<span class="fc" id="L552"> buffer[context.pos++] = pad;</span> -<span class="fc" id="L553"> break;</span> +<span class="fc" id="L580"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 19) & MASK_5BITS]; // 24-1*5 = 19</span> +<span class="fc" id="L581"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 14) & MASK_5BITS]; // 24-2*5 = 14</span> +<span class="fc" id="L582"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 9) & MASK_5BITS]; // 24-3*5 = 9</span> +<span class="fc" id="L583"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 4) & MASK_5BITS]; // 24-4*5 = 4</span> +<span class="fc" id="L584"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea << 1) & MASK_5BITS]; // 5-4 = 1</span> +<span class="fc" id="L585"> buffer[context.pos++] = pad;</span> +<span class="fc" id="L586"> buffer[context.pos++] = pad;</span> +<span class="fc" id="L587"> buffer[context.pos++] = pad;</span> +<span class="fc" id="L588"> break;</span> case 4: // 4 octets = 32 bits to use -<span class="fc" id="L555"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 27) & MASK_5BITS]; // 32-1*5 = 27</span> -<span class="fc" id="L556"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 22) & MASK_5BITS]; // 32-2*5 = 22</span> -<span class="fc" id="L557"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 17) & MASK_5BITS]; // 32-3*5 = 17</span> -<span class="fc" id="L558"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 12) & MASK_5BITS]; // 32-4*5 = 12</span> -<span class="fc" id="L559"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 7) & MASK_5BITS]; // 32-5*5 = 7</span> -<span class="fc" id="L560"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 2) & MASK_5BITS]; // 32-6*5 = 2</span> -<span class="fc" id="L561"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea << 3) & MASK_5BITS]; // 5-2 = 3</span> -<span class="fc" id="L562"> buffer[context.pos++] = pad;</span> -<span class="fc" id="L563"> break;</span> +<span class="fc" id="L590"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 27) & MASK_5BITS]; // 32-1*5 = 27</span> +<span class="fc" id="L591"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 22) & MASK_5BITS]; // 32-2*5 = 22</span> +<span class="fc" id="L592"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 17) & MASK_5BITS]; // 32-3*5 = 17</span> +<span class="fc" id="L593"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 12) & MASK_5BITS]; // 32-4*5 = 12</span> +<span class="fc" id="L594"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 7) & MASK_5BITS]; // 32-5*5 = 7</span> +<span class="fc" id="L595"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 2) & MASK_5BITS]; // 32-6*5 = 2</span> +<span class="fc" id="L596"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea << 3) & MASK_5BITS]; // 5-2 = 3</span> +<span class="fc" id="L597"> buffer[context.pos++] = pad;</span> +<span class="fc" id="L598"> break;</span> default: -<span class="nc" id="L565"> throw new IllegalStateException("Impossible modulus " + context.modulus);</span> +<span class="nc" id="L600"> throw new IllegalStateException("Impossible modulus " + context.modulus);</span> } -<span class="fc" id="L567"> context.currentLinePos += context.pos - savedPos; // keep track of current line position</span> +<span class="fc" id="L602"> context.currentLinePos += context.pos - savedPos; // keep track of current line position</span> // if currentPos == 0 we are at the start of a line, so don't add CRLF -<span class="fc bfc" id="L569" title="All 4 branches covered."> if (lineLength > 0 && context.currentLinePos > 0) { // add chunk separator if required</span> -<span class="fc" id="L570"> System.arraycopy(lineSeparator, 0, buffer, context.pos, lineSeparator.length);</span> -<span class="fc" id="L571"> context.pos += lineSeparator.length;</span> +<span class="fc bfc" id="L604" title="All 4 branches covered."> if (lineLength > 0 && context.currentLinePos > 0) { // add chunk separator if required</span> +<span class="fc" id="L605"> System.arraycopy(lineSeparator, 0, buffer, context.pos, lineSeparator.length);</span> +<span class="fc" id="L606"> context.pos += lineSeparator.length;</span> } -<span class="fc" id="L573"> } else {</span> -<span class="fc bfc" id="L574" title="All 2 branches covered."> for (int i = 0; i < inAvail; i++) {</span> -<span class="fc" id="L575"> final byte[] buffer = ensureBufferSize(encodeSize, context);</span> -<span class="fc" id="L576"> context.modulus = (context.modulus + 1) % BYTES_PER_UNENCODED_BLOCK;</span> -<span class="fc" id="L577"> int b = input[inPos++];</span> -<span class="fc bfc" id="L578" title="All 2 branches covered."> if (b < 0) {</span> -<span class="fc" id="L579"> b += 256;</span> +<span class="fc" id="L608"> } else {</span> +<span class="fc bfc" id="L609" title="All 2 branches covered."> for (int i = 0; i < inAvail; i++) {</span> +<span class="fc" id="L610"> final byte[] buffer = ensureBufferSize(encodeSize, context);</span> +<span class="fc" id="L611"> context.modulus = (context.modulus + 1) % BYTES_PER_UNENCODED_BLOCK;</span> +<span class="fc" id="L612"> int b = input[inPos++];</span> +<span class="fc bfc" id="L613" title="All 2 branches covered."> if (b < 0) {</span> +<span class="fc" id="L614"> b += 256;</span> } -<span class="fc" id="L581"> context.lbitWorkArea = (context.lbitWorkArea << 8) + b; // BITS_PER_BYTE</span> -<span class="fc bfc" id="L582" title="All 2 branches covered."> if (0 == context.modulus) { // we have enough bytes to create our output</span> -<span class="fc" id="L583"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 35) & MASK_5BITS];</span> -<span class="fc" id="L584"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 30) & MASK_5BITS];</span> -<span class="fc" id="L585"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 25) & MASK_5BITS];</span> -<span class="fc" id="L586"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 20) & MASK_5BITS];</span> -<span class="fc" id="L587"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 15) & MASK_5BITS];</span> -<span class="fc" id="L588"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 10) & MASK_5BITS];</span> -<span class="fc" id="L589"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 5) & MASK_5BITS];</span> -<span class="fc" id="L590"> buffer[context.pos++] = encodeTable[(int) context.lbitWorkArea & MASK_5BITS];</span> -<span class="fc" id="L591"> context.currentLinePos += BYTES_PER_ENCODED_BLOCK;</span> -<span class="fc bfc" id="L592" title="All 4 branches covered."> if (lineLength > 0 && lineLength <= context.currentLinePos) {</span> -<span class="fc" id="L593"> System.arraycopy(lineSeparator, 0, buffer, context.pos, lineSeparator.length);</span> -<span class="fc" id="L594"> context.pos += lineSeparator.length;</span> -<span class="fc" id="L595"> context.currentLinePos = 0;</span> +<span class="fc" id="L616"> context.lbitWorkArea = (context.lbitWorkArea << 8) + b; // BITS_PER_BYTE</span> +<span class="fc bfc" id="L617" title="All 2 branches covered."> if (0 == context.modulus) { // we have enough bytes to create our output</span> +<span class="fc" id="L618"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 35) & MASK_5BITS];</span> +<span class="fc" id="L619"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 30) & MASK_5BITS];</span> +<span class="fc" id="L620"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 25) & MASK_5BITS];</span> +<span class="fc" id="L621"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 20) & MASK_5BITS];</span> +<span class="fc" id="L622"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 15) & MASK_5BITS];</span> +<span class="fc" id="L623"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 10) & MASK_5BITS];</span> +<span class="fc" id="L624"> buffer[context.pos++] = encodeTable[(int) (context.lbitWorkArea >> 5) & MASK_5BITS];</span> +<span class="fc" id="L625"> buffer[context.pos++] = encodeTable[(int) context.lbitWorkArea & MASK_5BITS];</span> +<span class="fc" id="L626"> context.currentLinePos += BYTES_PER_ENCODED_BLOCK;</span> +<span class="fc bfc" id="L627" title="All 4 branches covered."> if (lineLength > 0 && lineLength <= context.currentLinePos) {</span> +<span class="fc" id="L628"> System.arraycopy(lineSeparator, 0, buffer, context.pos, lineSeparator.length);</span> +<span class="fc" id="L629"> context.pos += lineSeparator.length;</span> +<span class="fc" id="L630"> context.currentLinePos = 0;</span> } } } } -<span class="fc" id="L600"> }</span> +<span class="fc" id="L635"> }</span> /** * Gets the line separator (for testing only). @@ -605,7 +640,7 @@ public class Base32 extends BaseNCodec { * @return the line separator. */ byte[] getLineSeparator() { -<span class="fc" id="L608"> return lineSeparator;</span> +<span class="fc" id="L643"> return lineSeparator;</span> } /** @@ -616,7 +651,7 @@ public class Base32 extends BaseNCodec { */ @Override public boolean isInAlphabet(final byte octet) { -<span class="fc bfc" id="L619" title="All 6 branches covered."> return octet >= 0 && octet < decodeTable.length && decodeTable[octet] != -1;</span> +<span class="fc bfc" id="L654" title="All 6 branches covered."> return octet >= 0 && octet < decodeTable.length && decodeTable[octet] != -1;</span> } /** @@ -632,11 +667,11 @@ public class Base32 extends BaseNCodec { */ private void validateCharacter(final long emptyBitsMask, final Context context) { // Use the long bit work area -<span class="fc bfc" id="L635" title="All 4 branches covered."> if (isStrictDecoding() && (context.lbitWorkArea & emptyBitsMask) != 0) {</span> -<span class="fc" id="L636"> throw new IllegalArgumentException("Strict decoding: Last encoded character (before the paddings if any) is a valid " +</span> +<span class="fc bfc" id="L670" title="All 4 branches covered."> if (isStrictDecoding() && (context.lbitWorkArea & emptyBitsMask) != 0) {</span> +<span class="fc" id="L671"> throw new IllegalArgumentException("Strict decoding: Last encoded character (before the paddings if any) is a valid " +</span> "base 32 alphabet but not a possible encoding. Expected the discarded bits from the character to be zero."); } -<span class="fc" id="L639"> }</span> +<span class="fc" id="L674"> }</span> /** * Validates whether decoding allows final trailing characters that cannot be created during encoding. @@ -644,10 +679,10 @@ public class Base32 extends BaseNCodec { * @throws IllegalArgumentException if strict decoding is enabled */ private void validateTrailingCharacters() { -<span class="fc bfc" id="L647" title="All 2 branches covered."> if (isStrictDecoding()) {</span> -<span class="fc" id="L648"> throw new IllegalArgumentException("Strict decoding: Last encoded character(s) (before the paddings if any) are valid " +</span> +<span class="fc bfc" id="L682" title="All 2 branches covered."> if (isStrictDecoding()) {</span> +<span class="fc" id="L683"> throw new IllegalArgumentException("Strict decoding: Last encoded character(s) (before the paddings if any) are valid " +</span> "base 32 alphabet but not a possible encoding. Decoding requires either 2, 4, 5, or 7 trailing 5-bit characters to create bytes."); } -<span class="fc" id="L651"> }</span> +<span class="fc" id="L686"> }</span> } </pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html> \ No newline at end of file
Modified: websites/production/commons/content/proper/commons-codec/jacoco/org.apache.commons.codec.binary/Base32InputStream.java.html ============================================================================== --- websites/production/commons/content/proper/commons-codec/jacoco/org.apache.commons.codec.binary/Base32InputStream.java.html (original) +++ websites/production/commons/content/proper/commons-codec/jacoco/org.apache.commons.codec.binary/Base32InputStream.java.html Mon Jan 27 18:12:24 2025 @@ -22,7 +22,7 @@ import java.io.InputStream; import org.apache.commons.codec.CodecPolicy; /** - * Provides Base32 encoding and decoding in a streaming fashion (unlimited size). When encoding the default lineLength + * Provides Base32 decoding in a streaming fashion (unlimited size). When encoding the default lineLength * is 76 characters and the default lineEnding is CRLF, but these can be overridden by using the appropriate * constructor. * <p> @@ -90,7 +90,7 @@ public class Base32InputStream extends B * the nearest multiple of 4). If lineLength &lt;= 0, the encoded data is not divided into lines. If * doEncode is false, lineLength is ignored. * @param lineSeparator - * If doEncode is true, each line of encoded data will be terminated with this byte sequence (e.g. \r\n). + * If doEncode is true, each line of encoded data will be terminated with this byte sequence (for example \r\n). * If lineLength &lt;= 0, the lineSeparator is not used. If doEncode is false lineSeparator is ignored. */ public Base32InputStream(final InputStream inputStream, final boolean doEncode, final int lineLength, final byte[] lineSeparator) { @@ -110,7 +110,7 @@ public class Base32InputStream extends B * the nearest multiple of 4). If lineLength &lt;= 0, the encoded data is not divided into lines. If * doEncode is false, lineLength is ignored. * @param lineSeparator - * If doEncode is true, each line of encoded data will be terminated with this byte sequence (e.g. \r\n). + * If doEncode is true, each line of encoded data will be terminated with this byte sequence (for example \r\n). * If lineLength &lt;= 0, the lineSeparator is not used. If doEncode is false lineSeparator is ignored. * @param decodingPolicy * The decoding policy. Modified: websites/production/commons/content/proper/commons-codec/jacoco/org.apache.commons.codec.binary/Base32OutputStream.java.html ============================================================================== --- websites/production/commons/content/proper/commons-codec/jacoco/org.apache.commons.codec.binary/Base32OutputStream.java.html (original) +++ websites/production/commons/content/proper/commons-codec/jacoco/org.apache.commons.codec.binary/Base32OutputStream.java.html Mon Jan 27 18:12:24 2025 @@ -22,7 +22,7 @@ import java.io.OutputStream; import org.apache.commons.codec.CodecPolicy; /** - * Provides Base32 encoding and decoding in a streaming fashion (unlimited size). When encoding the default lineLength + * Provides Base32 encoding in a streaming fashion (unlimited size). When encoding the default lineLength * is 76 characters and the default lineEnding is CRLF, but these can be overridden by using the appropriate * constructor. * <p> @@ -94,7 +94,7 @@ public class Base32OutputStream extends * the nearest multiple of 4). If lineLength &lt;= 0, the encoded data is not divided into lines. If * doEncode is false, lineLength is ignored. * @param lineSeparator - * If doEncode is true, each line of encoded data will be terminated with this byte sequence (e.g. \r\n). + * If doEncode is true, each line of encoded data will be terminated with this byte sequence (for example \r\n). * If lineLength &lt;= 0, the lineSeparator is not used. If doEncode is false lineSeparator is ignored. */ public Base32OutputStream(final OutputStream outputStream, final boolean doEncode, final int lineLength, final byte[] lineSeparator) { @@ -114,7 +114,7 @@ public class Base32OutputStream extends * the nearest multiple of 4). If lineLength &lt;= 0, the encoded data is not divided into lines. If * doEncode is false, lineLength is ignored. * @param lineSeparator - * If doEncode is true, each line of encoded data will be terminated with this byte sequence (e.g. \r\n). + * If doEncode is true, each line of encoded data will be terminated with this byte sequence (for example \r\n). * If lineLength &lt;= 0, the lineSeparator is not used. If doEncode is false lineSeparator is ignored. * @param decodingPolicy The decoding policy. * @since 1.15 Modified: websites/production/commons/content/proper/commons-codec/jacoco/org.apache.commons.codec.binary/Base64.java.html ============================================================================== --- websites/production/commons/content/proper/commons-codec/jacoco/org.apache.commons.codec.binary/Base64.java.html (original) +++ websites/production/commons/content/proper/commons-codec/jacoco/org.apache.commons.codec.binary/Base64.java.html Mon Jan 27 18:12:24 2025 @@ -721,7 +721,7 @@ public class Base64 extends BaseNCodec { * call is not necessary when decoding, but it doesn't hurt, either. * </p> * <p> - * Ignores all non-base64 characters. This is how chunked (e.g. 76 character) data is handled, since CR and LF are + * Ignores all non-base64 characters. This is how chunked (for example 76 character) data is handled, since CR and LF are * silently ignored, but has implications for other bytes, too. This method subscribes to the garbage-in, * garbage-out philosophy: it will not check the provided data for validity. * </p> Modified: websites/production/commons/content/proper/commons-codec/jacoco/org.apache.commons.codec.binary/Base64InputStream.java.html ============================================================================== --- websites/production/commons/content/proper/commons-codec/jacoco/org.apache.commons.codec.binary/Base64InputStream.java.html (original) +++ websites/production/commons/content/proper/commons-codec/jacoco/org.apache.commons.codec.binary/Base64InputStream.java.html Mon Jan 27 18:12:24 2025 @@ -22,7 +22,7 @@ import java.io.InputStream; import org.apache.commons.codec.CodecPolicy; /** - * Provides Base64 encoding and decoding in a streaming fashion (unlimited size). When encoding the default lineLength + * Provides Base64 decoding in a streaming fashion (unlimited size). When encoding the default lineLength * is 76 characters and the default lineEnding is CRLF, but these can be overridden by using the appropriate * constructor. * <p> @@ -94,7 +94,7 @@ public class Base64InputStream extends B * the nearest multiple of 4). If lineLength &lt;= 0, the encoded data is not divided into lines. If * doEncode is false, lineLength is ignored. * @param lineSeparator - * If doEncode is true, each line of encoded data will be terminated with this byte sequence (e.g. \r\n). + * If doEncode is true, each line of encoded data will be terminated with this byte sequence (for example \r\n). * If lineLength &lt;= 0, the lineSeparator is not used. If doEncode is false lineSeparator is ignored. */ public Base64InputStream(final InputStream inputStream, final boolean doEncode, final int lineLength, final byte[] lineSeparator) { @@ -114,7 +114,7 @@ public class Base64InputStream extends B * the nearest multiple of 4). If lineLength &lt;= 0, the encoded data is not divided into lines. If * doEncode is false, lineLength is ignored. * @param lineSeparator - * If doEncode is true, each line of encoded data will be terminated with this byte sequence (e.g. \r\n). + * If doEncode is true, each line of encoded data will be terminated with this byte sequence (for example \r\n). * If lineLength &lt;= 0, the lineSeparator is not used. If doEncode is false lineSeparator is ignored. * @param decodingPolicy The decoding policy. * @since 1.15 Modified: websites/production/commons/content/proper/commons-codec/jacoco/org.apache.commons.codec.binary/Base64OutputStream.java.html ============================================================================== --- websites/production/commons/content/proper/commons-codec/jacoco/org.apache.commons.codec.binary/Base64OutputStream.java.html (original) +++ websites/production/commons/content/proper/commons-codec/jacoco/org.apache.commons.codec.binary/Base64OutputStream.java.html Mon Jan 27 18:12:24 2025 @@ -22,7 +22,7 @@ import java.io.OutputStream; import org.apache.commons.codec.CodecPolicy; /** - * Provides Base64 encoding and decoding in a streaming fashion (unlimited size). When encoding the default lineLength + * Provides Base64 encoding in a streaming fashion (unlimited size). When encoding the default lineLength * is 76 characters and the default lineEnding is CRLF, but these can be overridden by using the appropriate * constructor. * <p> @@ -98,7 +98,7 @@ public class Base64OutputStream extends * the nearest multiple of 4). If lineLength &lt;= 0, the encoded data is not divided into lines. If * doEncode is false, lineLength is ignored. * @param lineSeparator - * If doEncode is true, each line of encoded data will be terminated with this byte sequence (e.g. \r\n). + * If doEncode is true, each line of encoded data will be terminated with this byte sequence (for example \r\n). * If lineLength &lt;= 0, the lineSeparator is not used. If doEncode is false lineSeparator is ignored. */ public Base64OutputStream(final OutputStream outputStream, final boolean doEncode, final int lineLength, final byte[] lineSeparator) { @@ -118,7 +118,7 @@ public class Base64OutputStream extends * the nearest multiple of 4). If lineLength &lt;= 0, the encoded data is not divided into lines. If * doEncode is false, lineLength is ignored. * @param lineSeparator - * If doEncode is true, each line of encoded data will be terminated with this byte sequence (e.g. \r\n). + * If doEncode is true, each line of encoded data will be terminated with this byte sequence (for example \r\n). * If lineLength &lt;= 0, the lineSeparator is not used. If doEncode is false lineSeparator is ignored. * @param decodingPolicy The decoding policy. * @since 1.15 Modified: websites/production/commons/content/proper/commons-codec/jacoco/org.apache.commons.codec.binary/BaseNCodec.java.html ============================================================================== --- websites/production/commons/content/proper/commons-codec/jacoco/org.apache.commons.codec.binary/BaseNCodec.java.html (original) +++ websites/production/commons/content/proper/commons-codec/jacoco/org.apache.commons.codec.binary/BaseNCodec.java.html Mon Jan 27 18:12:24 2025 @@ -394,10 +394,10 @@ public abstract class BaseNCodec impleme /** Pad byte. Instance variable just in case it needs to vary later. */ protected final byte pad; - /** Number of bytes in each full block of unencoded data, e.g. 4 for Base64 and 5 for Base32 */ + /** Number of bytes in each full block of unencoded data, for example 4 for Base64 and 5 for Base32 */ private final int unencodedBlockSize; - /** Number of bytes in each full block of encoded data, e.g. 3 for Base64 and 8 for Base32 */ + /** Number of bytes in each full block of encoded data, for example 3 for Base64 and 8 for Base32 */ private final int encodedBlockSize; /** @@ -440,8 +440,8 @@ public abstract class BaseNCodec impleme * If {@code chunkSeparatorLength} is zero, then chunking is disabled. * </p> * - * @param unencodedBlockSize the size of an unencoded block (e.g. Base64 = 3) - * @param encodedBlockSize the size of an encoded block (e.g. Base64 = 4) + * @param unencodedBlockSize the size of an unencoded block (for example Base64 = 3) + * @param encodedBlockSize the size of an encoded block (for example Base64 = 4) * @param lineLength if &gt; 0, use chunking with a length {@code lineLength} * @param chunkSeparatorLength the chunk separator length, if relevant */ @@ -456,8 +456,8 @@ public abstract class BaseNCodec impleme * If {@code chunkSeparatorLength} is zero, then chunking is disabled. * </p> * - * @param unencodedBlockSize the size of an unencoded block (e.g. Base64 = 3) - * @param encodedBlockSize the size of an encoded block (e.g. Base64 = 4) + * @param unencodedBlockSize the size of an unencoded block (for example Base64 = 3) + * @param encodedBlockSize the size of an encoded block (for example Base64 = 4) * @param lineLength if &gt; 0, use chunking with a length {@code lineLength} * @param chunkSeparatorLength the chunk separator length, if relevant * @param pad byte used as padding byte. @@ -473,8 +473,8 @@ public abstract class BaseNCodec impleme * If {@code chunkSeparatorLength} is zero, then chunking is disabled. * </p> * - * @param unencodedBlockSize the size of an unencoded block (e.g. Base64 = 3) - * @param encodedBlockSize the size of an encoded block (e.g. Base64 = 4) + * @param unencodedBlockSize the size of an unencoded block (for example Base64 = 3) + * @param encodedBlockSize the size of an encoded block (for example Base64 = 4) * @param lineLength if &gt; 0, use chunking with a length {@code lineLength} * @param chunkSeparatorLength the chunk separator length, if relevant * @param pad byte used as padding byte.