Return-Path: X-Original-To: apmail-commons-commits-archive@minotaur.apache.org Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5094EDC39 for ; Sat, 6 Oct 2012 15:46:17 +0000 (UTC) Received: (qmail 58051 invoked by uid 500); 6 Oct 2012 15:46:17 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 58002 invoked by uid 500); 6 Oct 2012 15:46:17 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 57995 invoked by uid 99); 6 Oct 2012 15:46:17 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 06 Oct 2012 15:46:17 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 06 Oct 2012 15:46:14 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 1D049238896F for ; Sat, 6 Oct 2012 15:45:30 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1395101 - in /commons/proper/net/trunk/src: changes/changes.xml main/java/org/apache/commons/net/util/Base64.java Date: Sat, 06 Oct 2012 15:45:29 -0000 To: commits@commons.apache.org From: sebb@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121006154530.1D049238896F@eris.apache.org> Author: sebb Date: Sat Oct 6 15:45:29 2012 New Revision: 1395101 URL: http://svn.apache.org/viewvc?rev=1395101&view=rev Log: NET-484 Base64.CHUNK_SEPARATOR should be private Modified: commons/proper/net/trunk/src/changes/changes.xml commons/proper/net/trunk/src/main/java/org/apache/commons/net/util/Base64.java Modified: commons/proper/net/trunk/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/changes/changes.xml?rev=1395101&r1=1395100&r2=1395101&view=diff ============================================================================== --- commons/proper/net/trunk/src/changes/changes.xml (original) +++ commons/proper/net/trunk/src/changes/changes.xml Sat Oct 6 15:45:29 2012 @@ -66,6 +66,9 @@ The type attribute can be add,u This release fixes bugs and adds some new functionality (see below). It is binary compatible with previous releases "> + + Base64.CHUNK_SEPARATOR should be private + Base64.encodeBase64(byte[], boolean, boolean, int) does not calculate output size correctly for unchunked output. Modified: commons/proper/net/trunk/src/main/java/org/apache/commons/net/util/Base64.java URL: http://svn.apache.org/viewvc/commons/proper/net/trunk/src/main/java/org/apache/commons/net/util/Base64.java?rev=1395101&r1=1395100&r2=1395101&view=diff ============================================================================== --- commons/proper/net/trunk/src/main/java/org/apache/commons/net/util/Base64.java (original) +++ commons/proper/net/trunk/src/main/java/org/apache/commons/net/util/Base64.java Sat Oct 6 15:45:29 2012 @@ -68,13 +68,11 @@ public class Base64 { /** * Chunk separator per RFC 2045 section 2.1. * - *

- * N.B. The next major release may break compatibility and make this field private. - *

- * * @see RFC 2045 section 2.1 */ - static final byte[] CHUNK_SEPARATOR = {'\r', '\n'}; + private static final byte[] CHUNK_SEPARATOR = {'\r', '\n'}; + + private static final byte[] EMPTY_BYTE_ARRAY = new byte[0]; /** * This array is a lookup table that translates 6-bit positive integer index values into their "Base64 Alphabet" @@ -318,7 +316,7 @@ public class Base64 { public Base64(int lineLength, byte[] lineSeparator, boolean urlSafe) { if (lineSeparator == null) { lineLength = 0; // disable chunk-separating - lineSeparator = CHUNK_SEPARATOR; // this just gets ignored + lineSeparator = EMPTY_BYTE_ARRAY; // this just gets ignored } this.lineLength = lineLength > 0 ? (lineLength / 4) * 4 : 0; this.lineSeparator = new byte[lineSeparator.length]; @@ -845,7 +843,7 @@ public class Base64 { return binaryData; } - long len = getEncodeLength(binaryData, isChunked ? CHUNK_SIZE : 0, CHUNK_SEPARATOR); + long len = getEncodeLength(binaryData, isChunked ? CHUNK_SIZE : 0, isChunked ? CHUNK_SEPARATOR : EMPTY_BYTE_ARRAY); if (len > maxResultSize) { throw new IllegalArgumentException("Input array too big, the output array would be bigger (" + len +