-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
buffer: empty string is not a valid encoding #9661
Conversation
Buffer.isEncoding() relies on the internal utility function normalizeEncoding(), which converts falsey values to 'utf8'. This commit adds a check to Buffer.isEncoding() to catch the empty string, and return false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
semver-major?
It technically changes behavior, but I'd say it's purely a bug fix. The current behavior is just wrong. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and +1 to considering this a bugfix
Is it? I thought it kind of makes sense that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM, but can we make sure no one is relying on this behavior? cc @ChALkeR
IMO that doesn't make sense either, but it is what it is :-) @bnoordhuis do you have a preference on the semver-ness of this change, or even think this is a bug that should be fixed? |
I'm kind of with @bnoordhuis that treating |
This change affects |
Can we get to a consensus about this issue? I think |
Checklist
make -j8 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
buffer
Description of change
Buffer.isEncoding()
relies on the internal utility functionnormalizeEncoding()
, which converts falsey values to'utf8'
. This commit adds a check toBuffer.isEncoding()
to catch the emptystring, and return
false
.Fixes: #9654