fix-the-way-to-handle-codecs-in-the-system-icu.patch 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. From 4885090741554be61cb2ed10194cefb29bf8be64 Mon Sep 17 00:00:00 2001
  2. From: Yoshisato Yanagisawa <yyanagisawa@chromium.org>
  3. Date: Wed, 11 Jan 2023 23:51:39 +0000
  4. Subject: [PATCH] Fix the way to handle codecs in the system icu.
  5. The previous code does not register codecs whose standard name is
  6. different from the bundled ICU. As a result, looking up such codecs
  7. seems to fail unexpectedly.
  8. Bug: 1382032
  9. Change-Id: I8a61f77d0f70104415d24dd954b3b7061ffca556
  10. Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4154277
  11. Reviewed-by: Kent Tamura <tkent@chromium.org>
  12. Commit-Queue: Yoshisato Yanagisawa <yyanagisawa@chromium.org>
  13. Cr-Commit-Position: refs/heads/main@{#1091571}
  14. ---
  15. .../renderer/platform/wtf/text/text_codec_icu.cc | 14 ++++++++++----
  16. 1 file changed, 10 insertions(+), 4 deletions(-)
  17. 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
  18. index a70b359984f..33ce43f3563 100644
  19. --- a/third_party/blink/renderer/platform/wtf/text/text_codec_icu.cc
  20. +++ b/third_party/blink/renderer/platform/wtf/text/text_codec_icu.cc
  21. @@ -116,6 +116,10 @@ void TextCodecICU::RegisterEncodingNames(EncodingNameRegistrar registrar) {
  22. continue;
  23. }
  24. #endif
  25. + // Avoid codecs supported by `TextCodecCJK`.
  26. + if (is_text_codec_cjk_enabled && TextCodecCJK::IsSupported(standard_name)) {
  27. + continue;
  28. + }
  29. // A number of these aliases are handled in Chrome's copy of ICU, but
  30. // Chromium can be compiled with the system ICU.
  31. @@ -144,12 +148,13 @@ void TextCodecICU::RegisterEncodingNames(EncodingNameRegistrar registrar) {
  32. }
  33. #endif
  34. - if (is_text_codec_cjk_enabled && TextCodecCJK::IsSupported(standard_name)) {
  35. - continue;
  36. + // Avoid registering codecs registered by
  37. + // `TextCodecCJK::RegisterEncodingNames`.
  38. + if (!is_text_codec_cjk_enabled ||
  39. + !TextCodecCJK::IsSupported(standard_name)) {
  40. + registrar(standard_name, standard_name);
  41. }
  42. - registrar(standard_name, standard_name);
  43. -
  44. uint16_t num_aliases = ucnv_countAliases(name, &error);
  45. DCHECK(U_SUCCESS(error));
  46. if (U_SUCCESS(error))
  47. @@ -289,6 +294,7 @@ void TextCodecICU::RegisterCodecs(TextCodecRegistrar registrar) {
  48. continue;
  49. }
  50. #endif
  51. + // Avoid codecs supported by `TextCodecCJK`.
  52. if (is_text_codec_cjk_enabled && TextCodecCJK::IsSupported(standard_name)) {
  53. continue;
  54. }