Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-2906

Fix and improvement for Base64 encoding in GDK

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.5.6, 1.6-beta-1
    • 1.5.7, 1.6-beta-2
    • groovy-jdk
    • None
    • OS X, Java 1.5.0_13-119, Groovy from svn HEAD
    • Patch

    Description

      There are a couple of issues with the current implementation of Base64 encoding method on byte[] and Byte[] in the GDK.

      1) The current method is only for chunked (MIME-style) Base64 encoding. My patch adds an option to provide non-chunked Base64 encoding. It unit tests this new method, provides Javadoc comments for it, etc.
      2) The chunked implementation incorrectly chunked data into 75 characters per line. The spec (RFC2045) says it should be 76 characters per line. My patch fixes this and adds a unit test for this.
      3) The chunk separator is CRLF per the spec. My patch changes the separator to CRLF and adds a unit test for this as well
      4) Fixed minor spelling issues in Javadoc

      In addition to my unit tests here, I ran some tests on my local machine to make sure the output from Groovy's Base64 encoding matches the results from the Apache Commons Codec Base64 implementation. The results are now identical with the patch.

      There is one difficulty in applying this patch. The Groovy file groovy-core/src/test/groovy/Base64Test.groovy is set as binary in the Subversion repository, so I can't diff it. I have attached that file as well. It needs to be converted to text/plain.

      This issue came about from GRAILS-3039.

      Attachments

        1. OkReallyFixedNow.txt
          2 kB
          Drew Varner
        2. GroovyBase64PatchFinal.txt
          1 kB
          Drew Varner
        3. Base64Test.groovy
          2 kB
          Drew Varner
        4. GroovyBase64Patch.txt
          4 kB
          Drew Varner

        Activity

          People

            paulk Paul King
            varnerac Drew Varner
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: