| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
It is an open question though, what should be a proper behavior here. Should it just throw instead, or should it try to reset the encoding on stream? (There is no such API method atm, cc @nodejs/streams ) |
Sorry, something went wrong.
|
cc @nodejs/crypto |
Sorry, something went wrong.
There was a problem hiding this comment.
I think you can drop this line completely.
Sorry, something went wrong.
There was a problem hiding this comment.
Why?
Sorry, something went wrong.
There was a problem hiding this comment.
Isn't Buffer available everywhere without requiring it? I was able to apply your changes and run it without the require() and it worked fine for me.
Sorry, something went wrong.
There was a problem hiding this comment.
It is available, but I thought that we decided to not use globals as much as we can.
Sorry, something went wrong.
There was a problem hiding this comment.
Oh, I didn't know that. Ignore my comment then :-)
Sorry, something went wrong.
Are all string encodings guaranteed to make this fail? And, if you throw, can it be done so that the error can be caught? If not, maybe emit an error instead. |
Sorry, something went wrong.
|
@cjihrig I would say all of the encodings will make it fail depending on the particular input. I think it can emit error instead. |
Sorry, something went wrong.
|
@indutny Are you saying the data is converted from Buffer to String by setEncoding() and this converts it back to a Buffer? |
Sorry, something went wrong.
|
Yeah, not sure if it is a right thing to do, but at least it does not crash... |
Sorry, something went wrong.
|
@indutny may have a problem since v8 automatically strips invalid utf8 characters. so not guaranteed to preserve the data in all cases. |
Sorry, something went wrong.
|
Ok, going to make it emit error then. What about resetting the encoding, are we interested in APIs like this? |
Sorry, something went wrong.
|
I think resetting the encoding after someone explicitly sets it to something else will lead to a lot of confusion. |
Sorry, something went wrong.
If `.setEncoding` was called on input stream - all emitted `data` will be `String`s instances, not `Buffer`s. This is unacceptable for `StreamWrap`, and should not lead to the crash. Fix: nodejs#3970
|
PTAL |
Sorry, something went wrong.
There was a problem hiding this comment.
This is unused.
Sorry, something went wrong.
There was a problem hiding this comment.
Ack.
Sorry, something went wrong.
|
LGTM with comments. |
Sorry, something went wrong.
Sorry, something went wrong.
|
Unrelated CI failures, landing. |
Sorry, something went wrong.
|
@indutny ... should this go into v4 also? |
Sorry, something went wrong.
|
Actually, yes! Thank you @jasnell |
Sorry, something went wrong.
If `.setEncoding` was called on input stream - all emitted `data` will be `String`s instances, not `Buffer`s. This is unacceptable for `StreamWrap`, and should not lead to the crash. Fix: nodejs#3970 PR-URL: nodejs#4031 Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
| Back | FazBrowse Home | New Git URL |
When wrapping stream - cast its input data to Buffer before using.
Someone may have called .setEncoding() on it, and we should not crash
if the input is a string.
Fix: #3970