1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-01-07 06:46:59 -05:00

refactor(ext/web): Don't rely on NaN comparisons in TextEncoderStream (#13151)

In the `transform` function to `TextEncoderStream`'s internal
`TransformStream`, if `chunk` is the empty string and
`this.#pendingHighSurrogate` is null, then `lastCodeUnit` will be NaN.
As it turns out, this does not cause a bug because the comparison to
check for lone surrogates turns out to be false for NaN, but to rely on
it makes the code brittle.
This commit is contained in:
Andreu Botella 2022-01-05 00:42:30 +01:00 committed by Bartek Iwańczuk
parent 0721ee504d
commit 49ccfdd696
No known key found for this signature in database
GPG key ID: 0C6BCDDC3B3AD750

View file

@ -292,6 +292,9 @@
transform: (chunk, controller) => {
try {
chunk = webidl.converters.DOMString(chunk);
if (chunk === "") {
return PromiseResolve();
}
if (this.#pendingHighSurrogate !== null) {
chunk = this.#pendingHighSurrogate + chunk;
}