nodejs/node

TextDecoder does not error incorrectly for legacy byte sequences

Open

#40,091 建立於 2021年9月12日

在 GitHub 查看
 (12 留言) (4 反應) (0 負責人)JavaScript (35,535 fork)batch import
encodinggood first issue

倉庫指標

Star
 (117,218 star)
PR 合併指標
 (平均合併 13天 4小時) (30 天內合併 233 個 PR)

描述

Version

v16.9.1

Platform

Microsoft Windows NT 10.0.19043.0 x64

Subsystem

encoding

What steps will reproduce the bug?

Enter the following in the REPL:

new TextDecoder("Big5").decode(new Uint8Array([0x83, 0x5C])).charCodeAt(0).toString(16)

as well as

new TextDecoder("Big5").decode(new Uint8Array([0x83, 0x5C])).charCodeAt(1).toString(16)

How often does it reproduce? Is there a required condition?

Every time

What is the expected behavior?

fffd for the first, and 5c for the second (as in Firefox and Chrome, and per the WHATWG Encoding Standard)

What do you see instead?

f00e and NaN

Additional information

I suspect this has to do with you using ICU as-is, instead of properly patching it to match the Encoding Standard. There are probably more bugs like this.

@inexorabletash may be able to point to where in the Chromium source tree we keep our ICU encoding patches.

貢獻者指南