diff options
author | Andreu Botella <abb@randomunok.com> | 2022-01-05 00:42:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-05 00:42:30 +0100 |
commit | 22d140ffb194de38d842525907265e8a1ca51b04 (patch) | |
tree | b2ce2c982dcebb9a6c9ef4ef3746071d9c5e6a88 | |
parent | 19c8cd3a457b58bc62a6e0223ff78208a73d9435 (diff) |
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.
-rw-r--r-- | ext/web/08_text_encoding.js | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/ext/web/08_text_encoding.js b/ext/web/08_text_encoding.js index d2922a6d4..692909726 100644 --- a/ext/web/08_text_encoding.js +++ b/ext/web/08_text_encoding.js @@ -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; } |