Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.5.5
-
None
-
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.