Bug 216058 - Align UTF-16 decoder with Chrome, Firefox, and specification
Summary: Align UTF-16 decoder with Chrome, Firefox, and specification
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-09-01 16:32 PDT by Alex Christensen
Modified: 2020-09-02 14:19 PDT (History)
3 users (show)

See Also:


Attachments
Patch (11.29 KB, patch)
2020-09-01 16:34 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (18.53 KB, patch)
2020-09-01 18:47 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (19.13 KB, patch)
2020-09-01 19:41 PDT, Alex Christensen
youennf: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Christensen 2020-09-01 16:32:52 PDT
Align UTF-16 decoder with Chrome, Firefox, and specification
Comment 1 Alex Christensen 2020-09-01 16:34:21 PDT
Created attachment 407719 [details]
Patch
Comment 2 Alex Christensen 2020-09-01 18:47:04 PDT
Created attachment 407728 [details]
Patch
Comment 3 Alex Christensen 2020-09-01 19:41:56 PDT
Created attachment 407733 [details]
Patch
Comment 4 youenn fablet 2020-09-02 02:43:49 PDT
Comment on attachment 407733 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=407733&action=review

> Source/WebCore/platform/text/TextCodecUTF16.cpp:65
> +String TextCodecUTF16::decode(const char* bytes, size_t length, bool flush, bool, bool& sawError)

Can we reference https://encoding.spec.whatwg.org/#shared-utf-16-decoder
Comment 5 Alex Christensen 2020-09-02 07:45:48 PDT
http://trac.webkit.org/r266457
Comment 6 Radar WebKit Bug Importer 2020-09-02 07:46:14 PDT
<rdar://problem/68209549>
Comment 7 Darin Adler 2020-09-02 12:57:08 PDT
Comment on attachment 407733 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=407733&action=review

> Source/WebCore/platform/text/TextCodecUTF16.cpp:78
> +            if (codeUnit >= 0xDC00 && codeUnit <= 0xDFFF) {

If I was writing this code I would use U16_IS_LEAD here.

> Source/WebCore/platform/text/TextCodecUTF16.cpp:79
> +                result.appendCharacter(0x10000 + ((leadSurrogate - 0xD800) << 10) + codeUnit - 0xDC00);

U16_GET_SUPPLEMENTARY

> Source/WebCore/platform/text/TextCodecUTF16.cpp:87
> +        if (codeUnit >= 0xD800 && codeUnit <= 0xDBFF) {

U16_IS_LEAD

> Source/WebCore/platform/text/TextCodecUTF16.cpp:91
> +        if (codeUnit >= 0xDC00 && codeUnit <=0xDFFF) {

U16_IS_TRAIL
Comment 8 Alex Christensen 2020-09-02 14:19:13 PDT
Done in https://bugs.webkit.org/show_bug.cgi?id=216098