-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
proposal: encoding/baseXX: add Encoding.RejectLineFeeds #53845
Comments
An alternative and more flexible API is (per #54054 (comment)): // WithIgnored specifies a set of non-alphabet characters that are ignored
// when parsing the input. An empty string causes the encoder to reject
// all characters that are not part of the encoding alphabet.
// A newly created Encoder ignores '\r' and '\n' by default.
func (enc Encoding) WithIgnored(chars string) *Encoding My original proposal would be equivalent to |
Change https://go.dev/cl/532295 mentions this issue: |
This feature combined with #53844 makes it possible to implement a truly bijective mapping between baseXX and binary data. This would allow the use of |
golang/protobuf#1626 arose because the "google.golang.org/protobuf/encoding/protojson" package implicitly allowed newlines and carriage returns because the default behavior of the "base64" package is to ignore such characters. Having this option to begin with would have avoided that problem. |
I like the idea of |
Currently,
base32
andbase64
ignore carriage returns and linefeeds by default.This behavior goes against RFC 4648, sections 3.3 which state:
Rejection of "characters outside the base encoding alphabet" (including carriage returns and line feeds) should be the default,
unless specified otherwise by some higher-level specification (e.g., MIME).
The decision to allow
\r
or\n
should not have been made by thebase32
andbase64
packages,but rather by the users of it.
Today,
base32
andbase64
already ignore\r
and\n
by default and we can't change that,but we should expose control over this behavior:
The text was updated successfully, but these errors were encountered: