Skip to content

utf-16 TextDecoder is incorrect #4612

@ChALkeR

Description

@ChALkeR

It should always produce well-formed strings

Instead, this is what happens on utf-16le and utf-16be:

✖ FAIL Common implementation mistakes > Unicode > Invalid input is replaced > utf-16le
  AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
+ actual - expected

+ 'ab\ud800wx'
- 'ab�wx'
     ^
✖ FAIL Common implementation mistakes > Unicode > Invalid input is replaced > utf-16be
  AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
+ actual - expected

+ 'ab\ud800wx'
- 'ab�wx'
     ^

Libraries/users might rightfully assume that TextDecoder always produces well-formed strings, and not doing so is problematic.

This might have security implications due to:

  1. how hashes and signatures behave on non-well-formed strings
  2. not following fatal option

Metadata

Metadata

Assignees

Labels

C-BuiltinsPRs and Issues related to builtins/intrinsics

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions