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

fix base64 #28185

Closed
koggle opened this issue Oct 13, 2018 · 11 comments
Closed

fix base64 #28185

koggle opened this issue Oct 13, 2018 · 11 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@koggle
Copy link

koggle commented Oct 13, 2018

#28184

@koggle
Copy link
Author

koggle commented Oct 13, 2018

fmt.Println(base64.RawStdEncoding.DecodeString("ABCD"))
fmt.Println(base64.RawStdEncoding.DecodeString("ABC"))
fmt.Println(base64.RawStdEncoding.DecodeString("AB"))
fmt.Println(base64.RawStdEncoding.DecodeString("A"))

fmt.Println(base64.RawStdEncoding.DecodeString("ABC="))
fmt.Println(base64.RawStdEncoding.DecodeString("AB=="))

fmt.Println(base64.RawStdEncoding.DecodeString("ABC?"))
fmt.Println(base64.RawStdEncoding.DecodeString("AB?"))

//fixed
[0 16 131]
[0 16] illegal base64 data at input byte 2
[0] illegal base64 data at input byte 1
[] illegal base64 data at input byte 0
[0 16] illegal base64 data at input byte 3
[0] illegal base64 data at input byte 2
[0 16] illegal base64 data at input byte 3
[0] illegal base64 data at input byte 2

//bug
[0 16 131]
[0 16]
[0]
[] illegal base64 data at input byte 0
[] illegal base64 data at input byte 3
[] illegal base64 data at input byte 2
[] illegal base64 data at input byte 3
[] illegal base64 data at input byte 2

@koggle
Copy link
Author

koggle commented Oct 13, 2018

// fix bug, if we don't know the code is padding or nopading

@mvdan
Copy link
Member

mvdan commented Oct 14, 2018

To fix a bug, you first need to describe exactly what the bug is and how to reproduce it. Please follow the issue template to do that.

@mvdan mvdan added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Oct 14, 2018
@koggle
Copy link
Author

koggle commented Oct 15, 2018

fix the decodeQuantum and DecodedLen
my code link
https://play.golang.org/p/PRDLxcL5qcL

@koggle
Copy link
Author

koggle commented Oct 15, 2018

@ianlancetaylor
Copy link
Contributor

Please tell us what the problem is. Tell us exactly what you did, exactly what happened, and what you expected to have happen instead. Thanks.

@mattn
Copy link
Member

mattn commented Oct 15, 2018

@koggle As far as I can imagine from your pull-request and your codes on play.golang.org, you seems be pointing that RawStdEncoding doesn't handle on padding. But it works as expected. You should use StdEncoding instead of RawStdEncoding.

@koggle
Copy link
Author

koggle commented Oct 15, 2018

@mattn @ianlancetaylor @mvdan
Base64 is not a strict encoding format, it is just a storage format, so I think it is compatible in the decoding phase. The padding is only in the encoding process, and the decoding process should ignore the padding.

@koggle
Copy link
Author

koggle commented Oct 15, 2018

For example, I have two connections: aa://1234abc and aa://1234abc= This is not generated by me, it is someone else's, in fact, the content is the same. I need StdEncoding and RawStdEncoding for decoding, which doesn't look succinct. When you encounter this kind of aa://1234abc?, RawStdEncoding can't solve it at all.

@mvdan
Copy link
Member

mvdan commented Oct 15, 2018

This issue is still not following the clear steps outlined in the issue template. We're not getting any closer to that format, so I'm going to close this issue for now.

@koggle if you think there is a bug in the base64 package, please open a new issue and follow the template, clearly describing the bug and how to reproduce it.

@mvdan mvdan closed this as completed Oct 15, 2018
@mattn
Copy link
Member

mattn commented Oct 15, 2018

Do you expect strict encoder? Then please use RawStdEncoding.Strict().DecodeString(s).

@golang golang locked and limited conversation to collaborators Oct 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants