Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encoding/base64: seems to get confused by newlines #4779

Closed
rsc opened this issue Feb 9, 2013 · 8 comments
Closed

encoding/base64: seems to get confused by newlines #4779

rsc opened this issue Feb 9, 2013 · 8 comments
Labels
FrozenDueToAge Suggested Issues that may be good for new contributors looking for work to do.
Milestone

Comments

@rsc
Copy link
Contributor

rsc commented Feb 9, 2013

http://play.golang.org/p/GmsYyaq9HF
This still happens at tip, and I don't think it should.
tip claims to ignore newlines. 
Also input byte 677 is in the middle of a line.
@gopherbot
Copy link

Comment 1 by pkwarren:

I investigated this issue and found it was a problem with the decoder reading an
incomplete chunk of data if there is embedded whitespace.
I was able to fix this by wrapping the io.Reader in NewDecoder with a reader which
filters out whitespace. Does this sound like an ok approach? If so I'll create a review
request.

@gopherbot
Copy link

Comment 2 by pkwarren:

Created a changeset: https://golang.org/cl/7311069/

@davecheney
Copy link
Contributor

Comment 3:

fixed issue description, marked as started

Status changed to Started.

@gopherbot
Copy link

Comment 4 by remigius.gieben:

https://tools.ietf.org/html/rfc4648#section-3.1 says something about line-feeds in
encoded data. I don't see this is an issue, i.e. the current decoder works as
advertised. However if the golang-team wants to do something about this, should spaces
also be skipped when decoding?

@gopherbot
Copy link

Comment 5 by remigius.gieben:

The Decode() function works correctly. It is the Read function that is at fault. It
calculates the amount of data to read "nn := len(p) / 3 * 4", but disregards any 
line-feeds it might see when doing the io.ReadAtLeast(). 
I'm not sure how to proceed, create a new reader that removed line-feeds (and other
cruft) from the input?

@robpike
Copy link
Contributor

robpike commented Mar 8, 2013

Comment 6:

An injected Reader that drops \r and \n seems the simplest approach to me.

@gopherbot
Copy link

Comment 7 by remigius.gieben:

uploaded: https://golang.org/cl/7679043

@rsc
Copy link
Contributor Author

rsc commented Mar 12, 2013

Comment 8:

This issue was closed by revision b4237b5.

Status changed to Fixed.

@rsc rsc added fixed Suggested Issues that may be good for new contributors looking for work to do. labels Mar 12, 2013
@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge Suggested Issues that may be good for new contributors looking for work to do.
Projects
None yet
Development

No branches or pull requests

4 participants