You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Julius Davies (JIRA)" <ji...@apache.org> on 2010/03/27 05:30:28 UTC

[jira] Created: (CODEC-99) Base64.encodeBase64String() shouldn't chunk

Base64.encodeBase64String() shouldn't chunk
-------------------------------------------

                 Key: CODEC-99
                 URL: https://issues.apache.org/jira/browse/CODEC-99
             Project: Commons Codec
          Issue Type: Bug
    Affects Versions: 1.4
            Reporter: Julius Davies


Base64.encodeBase64String() shouldn't chunk.

Change this:

{code}
public static String encodeBase64String(byte[] binaryData) {
    return StringUtils.newStringUtf8(encodeBase64(binaryData, true));
}
{code}

To this:

{code}
public static String encodeBase64String(byte[] binaryData) {
    return StringUtils.newStringUtf8(encodeBase64(binaryData, true));
}
{code}



This will fix the following tests ggregory added a few minutes ago:

        //assertEquals("Zg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("f")));
        //assertEquals("Zm8=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fo")));
        //assertEquals("Zm9v", Base64.encodeBase64String(StringUtils.getBytesUtf8("foo")));
        //assertEquals("Zm9vYg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("foob")));
        //assertEquals("Zm9vYmE=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fooba")));
        //assertEquals("Zm9vYmFy", Base64.encodeBase64String(StringUtils.getBytesUtf8("foobar")));



-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CODEC-99) Base64.encodeBase64String() shouldn't chunk

Posted by "Julius Davies (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CODEC-99?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julius Davies updated CODEC-99:
-------------------------------

    Attachment: codec-99-tests.patch


Changes to unit-tests also attached.  Notice that two old tests assume the old, erroneous behavior, and so those need to be adjusted, too:

{code}
-        assertEquals("byteToString static Hello World", "SGVsbG8gV29ybGQ=\r\n", Base64.encodeBase64String(b1));
+        assertEquals("byteToString static Hello World", "SGVsbG8gV29ybGQ=", Base64.encodeBase64String(b1));


-        assertEquals("byteToString static UUID", "K/fMJwH+Q5e0nr7tWsxwkA==\r\n", Base64.encodeBase64String(b4));
+        assertEquals("byteToString static UUID", "K/fMJwH+Q5e0nr7tWsxwkA==", Base64.encodeBase64String(b4));
{code}

> Base64.encodeBase64String() shouldn't chunk
> -------------------------------------------
>
>                 Key: CODEC-99
>                 URL: https://issues.apache.org/jira/browse/CODEC-99
>             Project: Commons Codec
>          Issue Type: Bug
>    Affects Versions: 1.4
>            Reporter: Julius Davies
>         Attachments: codec-99-tests.patch, codec-99.patch
>
>
> Base64.encodeBase64String() shouldn't chunk.
> Change this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, true));
> }
> {code}
> To this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, false));
> }
> {code}
> This will fix the following tests ggregory added a few minutes ago:
>         //assertEquals("Zg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("f")));
>         //assertEquals("Zm8=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fo")));
>         //assertEquals("Zm9v", Base64.encodeBase64String(StringUtils.getBytesUtf8("foo")));
>         //assertEquals("Zm9vYg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("foob")));
>         //assertEquals("Zm9vYmE=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fooba")));
>         //assertEquals("Zm9vYmFy", Base64.encodeBase64String(StringUtils.getBytesUtf8("foobar")));

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CODEC-99) Base64.encodeBase64String() shouldn't chunk

Posted by "Gary Gregory (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CODEC-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12850626#action_12850626 ] 

Gary Gregory commented on CODEC-99:
-----------------------------------

IMO, the issue is not chunk vs. not chunk but that the output should never encode and end in a CR LR, especially when there is no = at the end of the output

> Base64.encodeBase64String() shouldn't chunk
> -------------------------------------------
>
>                 Key: CODEC-99
>                 URL: https://issues.apache.org/jira/browse/CODEC-99
>             Project: Commons Codec
>          Issue Type: Bug
>    Affects Versions: 1.4
>            Reporter: Julius Davies
>         Attachments: codec-99-test-fixes.patch, codec-99-tests.patch, codec-99.patch
>
>
> Base64.encodeBase64String() shouldn't chunk.
> Change this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, true));
> }
> {code}
> To this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, false));
> }
> {code}
> This will fix the following tests ggregory added a few minutes ago:
>         //assertEquals("Zg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("f")));
>         //assertEquals("Zm8=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fo")));
>         //assertEquals("Zm9v", Base64.encodeBase64String(StringUtils.getBytesUtf8("foo")));
>         //assertEquals("Zm9vYg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("foob")));
>         //assertEquals("Zm9vYmE=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fooba")));
>         //assertEquals("Zm9vYmFy", Base64.encodeBase64String(StringUtils.getBytesUtf8("foobar")));

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CODEC-99) Base64.encodeBase64String() shouldn't chunk

Posted by "Marc Ende (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CODEC-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12924892#action_12924892 ] 

Marc Ende  commented on CODEC-99:
---------------------------------

When I do:

Base64 encoder = new Base64(0); 
encoder.encodeBase64String(binaryData);

I would expect that the encoded string isn't chunked, I've set the appropriate settings in the
constructor before. But the current encodeBase64String() "overrides" the settings I've done.


> Base64.encodeBase64String() shouldn't chunk
> -------------------------------------------
>
>                 Key: CODEC-99
>                 URL: https://issues.apache.org/jira/browse/CODEC-99
>             Project: Commons Codec
>          Issue Type: Bug
>    Affects Versions: 1.4
>            Reporter: Julius Davies
>         Attachments: codec-99-test-fixes.patch, codec-99-tests.patch, codec-99.patch
>
>
> Base64.encodeBase64String() shouldn't chunk.
> Change this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, true));
> }
> {code}
> To this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, false));
> }
> {code}
> This will fix the following tests ggregory added a few minutes ago:
>         //assertEquals("Zg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("f")));
>         //assertEquals("Zm8=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fo")));
>         //assertEquals("Zm9v", Base64.encodeBase64String(StringUtils.getBytesUtf8("foo")));
>         //assertEquals("Zm9vYg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("foob")));
>         //assertEquals("Zm9vYmE=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fooba")));
>         //assertEquals("Zm9vYmFy", Base64.encodeBase64String(StringUtils.getBytesUtf8("foobar")));

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CODEC-99) Base64.encodeBase64String() shouldn't chunk

Posted by "Julius Davies (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CODEC-99?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julius Davies updated CODEC-99:
-------------------------------

    Description: 
Base64.encodeBase64String() shouldn't chunk.

Change this:

{code}
public static String encodeBase64String(byte[] binaryData) {
    return StringUtils.newStringUtf8(encodeBase64(binaryData, true));
}
{code}

To this:

{code}
public static String encodeBase64String(byte[] binaryData) {
    return StringUtils.newStringUtf8(encodeBase64(binaryData, false));
}
{code}



This will fix the following tests ggregory added a few minutes ago:

        //assertEquals("Zg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("f")));
        //assertEquals("Zm8=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fo")));
        //assertEquals("Zm9v", Base64.encodeBase64String(StringUtils.getBytesUtf8("foo")));
        //assertEquals("Zm9vYg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("foob")));
        //assertEquals("Zm9vYmE=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fooba")));
        //assertEquals("Zm9vYmFy", Base64.encodeBase64String(StringUtils.getBytesUtf8("foobar")));



  was:
Base64.encodeBase64String() shouldn't chunk.

Change this:

{code}
public static String encodeBase64String(byte[] binaryData) {
    return StringUtils.newStringUtf8(encodeBase64(binaryData, true));
}
{code}

To this:

{code}
public static String encodeBase64String(byte[] binaryData) {
    return StringUtils.newStringUtf8(encodeBase64(binaryData, true));
}
{code}



This will fix the following tests ggregory added a few minutes ago:

        //assertEquals("Zg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("f")));
        //assertEquals("Zm8=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fo")));
        //assertEquals("Zm9v", Base64.encodeBase64String(StringUtils.getBytesUtf8("foo")));
        //assertEquals("Zm9vYg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("foob")));
        //assertEquals("Zm9vYmE=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fooba")));
        //assertEquals("Zm9vYmFy", Base64.encodeBase64String(StringUtils.getBytesUtf8("foobar")));




> Base64.encodeBase64String() shouldn't chunk
> -------------------------------------------
>
>                 Key: CODEC-99
>                 URL: https://issues.apache.org/jira/browse/CODEC-99
>             Project: Commons Codec
>          Issue Type: Bug
>    Affects Versions: 1.4
>            Reporter: Julius Davies
>
> Base64.encodeBase64String() shouldn't chunk.
> Change this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, true));
> }
> {code}
> To this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, false));
> }
> {code}
> This will fix the following tests ggregory added a few minutes ago:
>         //assertEquals("Zg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("f")));
>         //assertEquals("Zm8=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fo")));
>         //assertEquals("Zm9v", Base64.encodeBase64String(StringUtils.getBytesUtf8("foo")));
>         //assertEquals("Zm9vYg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("foob")));
>         //assertEquals("Zm9vYmE=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fooba")));
>         //assertEquals("Zm9vYmFy", Base64.encodeBase64String(StringUtils.getBytesUtf8("foobar")));

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (CODEC-99) Base64.encodeBase64String() shouldn't chunk

Posted by "Julius Davies (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CODEC-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12850694#action_12850694 ] 

Julius Davies edited comment on CODEC-99 at 3/28/10 5:16 PM:
-------------------------------------------------------------

To respond to Gary, here is behaviour of Base64.encodeBase64Chunked(b) through all versions of commons-codec:

{code}
package playground;
import org.apache.commons.codec.binary.Base64;
public class Base64ChunkTest {

    public static void main(String[] args) throws Exception {
        byte[] b = args[0].getBytes("UTF-8");

        b = Base64.encodeBase64Chunked(b);

        String s = new String(b, "UTF-8");
        s = s.replace("\n", "\\n").replace("\r", "\\r");
        System.out.println(s);
    }
}
{code}

{noformat}
$ java -cp build/classes:lib/commons-codec-1.1.jar playground.Base64ChunkTest Hello
SGVsbG8=\n

$ java -cp build/classes:lib/commons-codec-1.2.jar playground.Base64ChunkTest Hello
SGVsbG8=\n

$ java -cp build/classes:lib/commons-codec-1.3.jar playground.Base64ChunkTest Hello
SGVsbG8=\r\n

$ java -cp build/classes:lib/commons-codec-1.4.jar playground.Base64ChunkTest Hello
SGVsbG8=\r\n
{noformat}


Just to be clear, you want to change this now after 7 years (the files in the commons-codec-1.1.jar have '2003-04-29' timestamps)?

ps.  I don't think '=' should be part of the equation, because valid data can encode and not have any '=' characters, for example the string '123':

{noformat}
$ java -cp build/classes:lib/commons-codec-1.4.jar playground.Base64ChunkTest 123
MTIz\r\n
{noformat}



      was (Author: juliusdavies):
    To respond to Gary, here is behaviour of Base64.encodeBase64Chunked(b) through all versions of commons-codec:

{code}
package playground;
import org.apache.commons.codec.binary.Base64;
public class Base64ChunkTest {

    public static void main(String[] args) throws Exception {
        byte[] b = args[0].getBytes("UTF-8");

        b = Base64.encodeBase64Chunked(b);

        String s = new String(b, "UTF-8");
        s = s.replace("\n", "\\n").replace("\r", "\\r");
        System.out.println(s);
    }
}
{code}

{noformat}
$ java -cp build/classes:lib/commons-codec-1.1.jar playground.Base64ChunkTest Hello
SGVsbG8=\n

$ java -cp build/classes:lib/commons-codec-1.2.jar playground.Base64ChunkTest Hello
SGVsbG8=\n

$ java -cp build/classes:lib/commons-codec-1.3.jar playground.Base64ChunkTest Hello
SGVsbG8=\r\n

$ java -cp build/classes:lib/commons-codec-1.4.jar playground.Base64ChunkTest Hello
SGVsbG8=\r\n
{noformat}
  
> Base64.encodeBase64String() shouldn't chunk
> -------------------------------------------
>
>                 Key: CODEC-99
>                 URL: https://issues.apache.org/jira/browse/CODEC-99
>             Project: Commons Codec
>          Issue Type: Bug
>    Affects Versions: 1.4
>            Reporter: Julius Davies
>         Attachments: codec-99-test-fixes.patch, codec-99-tests.patch, codec-99.patch
>
>
> Base64.encodeBase64String() shouldn't chunk.
> Change this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, true));
> }
> {code}
> To this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, false));
> }
> {code}
> This will fix the following tests ggregory added a few minutes ago:
>         //assertEquals("Zg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("f")));
>         //assertEquals("Zm8=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fo")));
>         //assertEquals("Zm9v", Base64.encodeBase64String(StringUtils.getBytesUtf8("foo")));
>         //assertEquals("Zm9vYg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("foob")));
>         //assertEquals("Zm9vYmE=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fooba")));
>         //assertEquals("Zm9vYmFy", Base64.encodeBase64String(StringUtils.getBytesUtf8("foobar")));

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CODEC-99) Base64.encodeBase64String() shouldn't chunk

Posted by "Jochen Wiedmann (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CODEC-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12924904#action_12924904 ] 

Jochen Wiedmann commented on CODEC-99:
--------------------------------------

You possibly wouldn't, because you are encoding a small string, like a password. Others would, because they are encoding a very large string. Whatever the default, if you need to be sure, don't use the convenience methods. Period!

The only reason for changing the default would be upwards compatibility. If we change it for other reasons, we loose upwards compatibility.


> Base64.encodeBase64String() shouldn't chunk
> -------------------------------------------
>
>                 Key: CODEC-99
>                 URL: https://issues.apache.org/jira/browse/CODEC-99
>             Project: Commons Codec
>          Issue Type: Bug
>    Affects Versions: 1.4
>            Reporter: Julius Davies
>         Attachments: codec-99-test-fixes.patch, codec-99-tests.patch, codec-99.patch
>
>
> Base64.encodeBase64String() shouldn't chunk.
> Change this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, true));
> }
> {code}
> To this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, false));
> }
> {code}
> This will fix the following tests ggregory added a few minutes ago:
>         //assertEquals("Zg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("f")));
>         //assertEquals("Zm8=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fo")));
>         //assertEquals("Zm9v", Base64.encodeBase64String(StringUtils.getBytesUtf8("foo")));
>         //assertEquals("Zm9vYg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("foob")));
>         //assertEquals("Zm9vYmE=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fooba")));
>         //assertEquals("Zm9vYmFy", Base64.encodeBase64String(StringUtils.getBytesUtf8("foobar")));

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CODEC-99) Base64.encodeBase64String() shouldn't chunk

Posted by "Gary Gregory (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CODEC-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12850602#action_12850602 ] 

Gary Gregory commented on CODEC-99:
-----------------------------------

Applied patch  https://issues.apache.org/jira/secure/attachment/12439949/codec-99-test-fixes.patch
Thank you Julius.

> Base64.encodeBase64String() shouldn't chunk
> -------------------------------------------
>
>                 Key: CODEC-99
>                 URL: https://issues.apache.org/jira/browse/CODEC-99
>             Project: Commons Codec
>          Issue Type: Bug
>    Affects Versions: 1.4
>            Reporter: Julius Davies
>         Attachments: codec-99-test-fixes.patch, codec-99-tests.patch, codec-99.patch
>
>
> Base64.encodeBase64String() shouldn't chunk.
> Change this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, true));
> }
> {code}
> To this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, false));
> }
> {code}
> This will fix the following tests ggregory added a few minutes ago:
>         //assertEquals("Zg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("f")));
>         //assertEquals("Zm8=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fo")));
>         //assertEquals("Zm9v", Base64.encodeBase64String(StringUtils.getBytesUtf8("foo")));
>         //assertEquals("Zm9vYg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("foob")));
>         //assertEquals("Zm9vYmE=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fooba")));
>         //assertEquals("Zm9vYmFy", Base64.encodeBase64String(StringUtils.getBytesUtf8("foobar")));

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CODEC-99) Base64.encodeBase64String() shouldn't chunk

Posted by "Marc Ende (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CODEC-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12924940#action_12924940 ] 

Marc Ende  commented on CODEC-99:
---------------------------------

If I'd like to encode a small string, I'll agree:

new Base64().encodeToString(...)

But it doesn't matter in this point if this is chunked or not. 

Other people which like to encode larger strings won't use new Base64(0) or new Base64(-1) when they wanted chunked
files. Otherwise they've read the docs which mentioned the way to use unchunked. I think it wouldn't break upwards compatibility because there is no really use case where you'll instantiate an Base64 encoder with 0 or less than 0 when it should be chunked. In these case even the "convenience methods" should behaviour correctly. Or otherwise (to keep upwards compatibility) it should be explicitly mentioned in the apidocs. 

Currently it looks like buying a car, choosing red as the color and only if you're opening the right door the car became green. 

> Base64.encodeBase64String() shouldn't chunk
> -------------------------------------------
>
>                 Key: CODEC-99
>                 URL: https://issues.apache.org/jira/browse/CODEC-99
>             Project: Commons Codec
>          Issue Type: Bug
>    Affects Versions: 1.4
>            Reporter: Julius Davies
>         Attachments: codec-99-test-fixes.patch, codec-99-tests.patch, codec-99.patch
>
>
> Base64.encodeBase64String() shouldn't chunk.
> Change this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, true));
> }
> {code}
> To this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, false));
> }
> {code}
> This will fix the following tests ggregory added a few minutes ago:
>         //assertEquals("Zg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("f")));
>         //assertEquals("Zm8=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fo")));
>         //assertEquals("Zm9v", Base64.encodeBase64String(StringUtils.getBytesUtf8("foo")));
>         //assertEquals("Zm9vYg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("foob")));
>         //assertEquals("Zm9vYmE=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fooba")));
>         //assertEquals("Zm9vYmFy", Base64.encodeBase64String(StringUtils.getBytesUtf8("foobar")));

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (CODEC-99) Base64.encodeBase64String() shouldn't chunk

Posted by "Marc Ende (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CODEC-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12924892#action_12924892 ] 

Marc Ende  edited comment on CODEC-99 at 10/26/10 4:33 AM:
-----------------------------------------------------------

When I do:

Base64 encoder = new Base64(0); 
encoder.encodeBase64String(binaryData);

I would expect that the encoded string isn't chunked, I've set the appropriate settings in the
constructor before. But the current encodeBase64String() "overrides" the settings I've done.

The methods encodeBase64String(..) and so on should respect the settings made in the constructor in my opinion.

      was (Author: me):
    When I do:

Base64 encoder = new Base64(0); 
encoder.encodeBase64String(binaryData);

I would expect that the encoded string isn't chunked, I've set the appropriate settings in the
constructor before. But the current encodeBase64String() "overrides" the settings I've done.

  
> Base64.encodeBase64String() shouldn't chunk
> -------------------------------------------
>
>                 Key: CODEC-99
>                 URL: https://issues.apache.org/jira/browse/CODEC-99
>             Project: Commons Codec
>          Issue Type: Bug
>    Affects Versions: 1.4
>            Reporter: Julius Davies
>         Attachments: codec-99-test-fixes.patch, codec-99-tests.patch, codec-99.patch
>
>
> Base64.encodeBase64String() shouldn't chunk.
> Change this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, true));
> }
> {code}
> To this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, false));
> }
> {code}
> This will fix the following tests ggregory added a few minutes ago:
>         //assertEquals("Zg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("f")));
>         //assertEquals("Zm8=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fo")));
>         //assertEquals("Zm9v", Base64.encodeBase64String(StringUtils.getBytesUtf8("foo")));
>         //assertEquals("Zm9vYg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("foob")));
>         //assertEquals("Zm9vYmE=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fooba")));
>         //assertEquals("Zm9vYmFy", Base64.encodeBase64String(StringUtils.getBytesUtf8("foobar")));

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CODEC-99) Base64.encodeBase64String() shouldn't chunk

Posted by "Julius Davies (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CODEC-99?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julius Davies updated CODEC-99:
-------------------------------

    Attachment: codec-99-test-fixes.patch

Some of the JUnit tests have a problem:

"Zm9v" + Base64.CHUNK_SEPARATOR

This results in:

Zm9v[B@6bbc4459

As opposed to:

Zm9v\r\n



codec-99-test-fixes.patch attached to fix this.




> Base64.encodeBase64String() shouldn't chunk
> -------------------------------------------
>
>                 Key: CODEC-99
>                 URL: https://issues.apache.org/jira/browse/CODEC-99
>             Project: Commons Codec
>          Issue Type: Bug
>    Affects Versions: 1.4
>            Reporter: Julius Davies
>         Attachments: codec-99-test-fixes.patch, codec-99-tests.patch, codec-99.patch
>
>
> Base64.encodeBase64String() shouldn't chunk.
> Change this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, true));
> }
> {code}
> To this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, false));
> }
> {code}
> This will fix the following tests ggregory added a few minutes ago:
>         //assertEquals("Zg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("f")));
>         //assertEquals("Zm8=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fo")));
>         //assertEquals("Zm9v", Base64.encodeBase64String(StringUtils.getBytesUtf8("foo")));
>         //assertEquals("Zm9vYg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("foob")));
>         //assertEquals("Zm9vYmE=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fooba")));
>         //assertEquals("Zm9vYmFy", Base64.encodeBase64String(StringUtils.getBytesUtf8("foobar")));

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (CODEC-99) Base64.encodeBase64String() shouldn't chunk

Posted by "Julius Davies (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/CODEC-99?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julius Davies updated CODEC-99:
-------------------------------

    Attachment: codec-99.patch

One-line patch to fix this attached.

> Base64.encodeBase64String() shouldn't chunk
> -------------------------------------------
>
>                 Key: CODEC-99
>                 URL: https://issues.apache.org/jira/browse/CODEC-99
>             Project: Commons Codec
>          Issue Type: Bug
>    Affects Versions: 1.4
>            Reporter: Julius Davies
>         Attachments: codec-99.patch
>
>
> Base64.encodeBase64String() shouldn't chunk.
> Change this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, true));
> }
> {code}
> To this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, false));
> }
> {code}
> This will fix the following tests ggregory added a few minutes ago:
>         //assertEquals("Zg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("f")));
>         //assertEquals("Zm8=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fo")));
>         //assertEquals("Zm9v", Base64.encodeBase64String(StringUtils.getBytesUtf8("foo")));
>         //assertEquals("Zm9vYg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("foob")));
>         //assertEquals("Zm9vYmE=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fooba")));
>         //assertEquals("Zm9vYmFy", Base64.encodeBase64String(StringUtils.getBytesUtf8("foobar")));

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (CODEC-99) Base64.encodeBase64String() shouldn't chunk

Posted by "Julius Davies (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/CODEC-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12850694#action_12850694 ] 

Julius Davies commented on CODEC-99:
------------------------------------

To respond to Gary, here is behaviour of Base64.encodeBase64Chunked(b) through all versions of commons-codec:

{code}
package playground;
import org.apache.commons.codec.binary.Base64;
public class Base64ChunkTest {

    public static void main(String[] args) throws Exception {
        byte[] b = args[0].getBytes("UTF-8");

        b = Base64.encodeBase64Chunked(b);

        String s = new String(b, "UTF-8");
        s = s.replace("\n", "\\n").replace("\r", "\\r");
        System.out.println(s);
    }
}
{code}

{noformat}
$ java -cp build/classes:lib/commons-codec-1.1.jar playground.Base64ChunkTest Hello
SGVsbG8=\n

$ java -cp build/classes:lib/commons-codec-1.2.jar playground.Base64ChunkTest Hello
SGVsbG8=\n

$ java -cp build/classes:lib/commons-codec-1.3.jar playground.Base64ChunkTest Hello
SGVsbG8=\r\n

$ java -cp build/classes:lib/commons-codec-1.4.jar playground.Base64ChunkTest Hello
SGVsbG8=\r\n
{noformat}

> Base64.encodeBase64String() shouldn't chunk
> -------------------------------------------
>
>                 Key: CODEC-99
>                 URL: https://issues.apache.org/jira/browse/CODEC-99
>             Project: Commons Codec
>          Issue Type: Bug
>    Affects Versions: 1.4
>            Reporter: Julius Davies
>         Attachments: codec-99-test-fixes.patch, codec-99-tests.patch, codec-99.patch
>
>
> Base64.encodeBase64String() shouldn't chunk.
> Change this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, true));
> }
> {code}
> To this:
> {code}
> public static String encodeBase64String(byte[] binaryData) {
>     return StringUtils.newStringUtf8(encodeBase64(binaryData, false));
> }
> {code}
> This will fix the following tests ggregory added a few minutes ago:
>         //assertEquals("Zg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("f")));
>         //assertEquals("Zm8=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fo")));
>         //assertEquals("Zm9v", Base64.encodeBase64String(StringUtils.getBytesUtf8("foo")));
>         //assertEquals("Zm9vYg==", Base64.encodeBase64String(StringUtils.getBytesUtf8("foob")));
>         //assertEquals("Zm9vYmE=", Base64.encodeBase64String(StringUtils.getBytesUtf8("fooba")));
>         //assertEquals("Zm9vYmFy", Base64.encodeBase64String(StringUtils.getBytesUtf8("foobar")));

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.