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

byte[].encodeBase64() incorrectly introduces line breaks

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.5
    • Fix Version/s: 1.5.7, 1.6-beta-2
    • Component/s: None
    • Labels:
      None

      Description

      Groovy's encodeBase64 inserts 0x0A chars (LF) into long strings to break lines. This is contrary to my reading of RFC4648:

      {codec}
      3.1. Line Feeds in Encoded Data

      MIME [4] is often used as a reference for base 64 encoding. However,
      MIME does not define "base 64" per se, but rather a "base 64 Content-
      Transfer-Encoding" for use within MIME. As such, MIME enforces a
      limit on line length of base 64-encoded data to 76 characters. MIME
      inherits the encoding from Privacy Enhanced Mail (PEM) [3], stating
      that it is "virtually identical"; however, PEM uses a line length of
      64 characters. The MIME and PEM limits are both due to limits within
      SMTP.

      Implementations MUST NOT add line feeds to base-encoded data unless
      the specification referring to this document explicitly directs base
      encoders to add line feeds after a specific number of characters.{codec}

      This has resulted in incorrect behaviour in Grails also. However the author notes that some groovy applications may rely on this functionality currently, so this could be a breaking change for some.

      It would be better to be correct IMO. There is no clue in groovy docs that this introduces line breaks in this MIME/SMTP specific way.

        Attachments

          Activity

            People

            • Assignee:
              paulk Paul King
              Reporter:
              marc@anyware.co.uk Marc Palmer
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: