1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-23 15:49:44 -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 GitHub
parent 19c8cd3a45
commit 22d140ffb1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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;
}