summaryrefslogtreecommitdiffstats
path: root/fix-the-way-to-handle-codecs-in-the-system-icu.patch
blob: 63c4cee930ea8eedc6396f035c16953a65d47971 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
From 4885090741554be61cb2ed10194cefb29bf8be64 Mon Sep 17 00:00:00 2001
From: Yoshisato Yanagisawa <yyanagisawa@chromium.org>
Date: Wed, 11 Jan 2023 23:51:39 +0000
Subject: [PATCH] Fix the way to handle codecs in the system icu.

The previous code does not register codecs whose standard name is
different from the bundled ICU.  As a result, looking up such codecs
seems to fail unexpectedly.

Bug: 1382032
Change-Id: I8a61f77d0f70104415d24dd954b3b7061ffca556
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4154277
Reviewed-by: Kent Tamura <tkent@chromium.org>
Commit-Queue: Yoshisato Yanagisawa <yyanagisawa@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1091571}
---
 .../renderer/platform/wtf/text/text_codec_icu.cc   | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/third_party/blink/renderer/platform/wtf/text/text_codec_icu.cc b/third_party/blink/renderer/platform/wtf/text/text_codec_icu.cc
index a70b359984f..33ce43f3563 100644
--- a/third_party/blink/renderer/platform/wtf/text/text_codec_icu.cc
+++ b/third_party/blink/renderer/platform/wtf/text/text_codec_icu.cc
@@ -116,6 +116,10 @@ void TextCodecICU::RegisterEncodingNames(EncodingNameRegistrar registrar) {
       continue;
     }
 #endif
+    // Avoid codecs supported by `TextCodecCJK`.
+    if (is_text_codec_cjk_enabled && TextCodecCJK::IsSupported(standard_name)) {
+      continue;
+    }
 
 // A number of these aliases are handled in Chrome's copy of ICU, but
 // Chromium can be compiled with the system ICU.
@@ -144,12 +148,13 @@ void TextCodecICU::RegisterEncodingNames(EncodingNameRegistrar registrar) {
     }
 #endif
 
-    if (is_text_codec_cjk_enabled && TextCodecCJK::IsSupported(standard_name)) {
-      continue;
+    // Avoid registering codecs registered by
+    // `TextCodecCJK::RegisterEncodingNames`.
+    if (!is_text_codec_cjk_enabled ||
+        !TextCodecCJK::IsSupported(standard_name)) {
+      registrar(standard_name, standard_name);
     }
 
-    registrar(standard_name, standard_name);
-
     uint16_t num_aliases = ucnv_countAliases(name, &error);
     DCHECK(U_SUCCESS(error));
     if (U_SUCCESS(error))
@@ -289,6 +294,7 @@ void TextCodecICU::RegisterCodecs(TextCodecRegistrar registrar) {
       continue;
     }
 #endif
+    // Avoid codecs supported by `TextCodecCJK`.
     if (is_text_codec_cjk_enabled && TextCodecCJK::IsSupported(standard_name)) {
       continue;
     }