Skip to content

Strip newlines from base 64 encoder. #3

Merged
merged 2 commits into from May 6, 2011

5 participants

@kmonkeyjam

We used to pass in a don't use newline flag when we used the apache commons codec base 64 encoder. There is not such a flag in the sun.misc encoder. If you override the bytesPerLine method to return Int.MaxInt, it will give you a heap overflow. So we just explicitly strip them.

@stevej
stevej commented Apr 6, 2011
@kmonkeyjam
@kmonkeyjam
@9len
9len commented Apr 6, 2011

can we add a test to make sure that the decoder doesn't care about newlines one way or the other?

@kmonkeyjam

Added a test.

@9len
9len commented Apr 6, 2011

birdcage/util is now the canonical home of util code changes, the change should be made there...

@kmonkeyjam
@9len
9len commented Apr 6, 2011

birdcage is an internal repo.

@robey
robey commented May 6, 2011

i'll just merge it here.

@robey robey merged commit 2275ced into twitter:master May 6, 2011
@som-snytt

This change was zapped when the code was moved to util-codec, but the correct change would have been to override BASE64Encoder.encodeLineSuffix and not emit the newline. This change, to replace \n instead of util.Properties.lineSeparator, breaks on Windows (where some of us are dual-booted); or at least the test breaks, since the decoder ignores [\r\n]*. But this behavior is arguably wrong, in so far as CR-LF is called for, and is supplied by Commons Codec which is used now:
http://tools.ietf.org/html/rfc2045#section-2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.