Title: [224589] trunk
Revision
224589
Author
[email protected]
Date
2017-11-08 11:35:18 -0800 (Wed, 08 Nov 2017)

Log Message

iOS supports some text encodings supposedly due to lack of TEC that aren't supported by the TEC decoder on macOS
https://bugs.webkit.org/show_bug.cgi?id=179309

Reviewed by Darin Adler.

Source/WebCore:

Test: fast/encoding/legacy-ios-encodings.html

* platform/text/TextCodecICU.cpp:
(WebCore::TextCodecICU::registerEncodingNames): Remove most iOS-specific adding of names, leaving only softbank-sjis.
Most were either redundant or unnecessary.
(WebCore::TextCodecICU::registerCodecs): ditto

LayoutTests:

* fast/encoding/legacy-ios-encodings-expected.txt: Added.
* fast/encoding/legacy-ios-encodings.html: Added. Check that we don't support some old iOS-only encoding names
and check for some nonstandard encoding names that we do support (for now).

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (224588 => 224589)


--- trunk/LayoutTests/ChangeLog	2017-11-08 19:30:36 UTC (rev 224588)
+++ trunk/LayoutTests/ChangeLog	2017-11-08 19:35:18 UTC (rev 224589)
@@ -1,5 +1,16 @@
 2017-11-08  Maciej Stachowiak  <[email protected]>
 
+        iOS supports some text encodings supposedly due to lack of TEC that aren't supported by the TEC decoder on macOS
+        https://bugs.webkit.org/show_bug.cgi?id=179309
+
+        Reviewed by Darin Adler.
+
+        * fast/encoding/legacy-ios-encodings-expected.txt: Added.
+        * fast/encoding/legacy-ios-encodings.html: Added. Check that we don't support some old iOS-only encoding names
+        and check for some nonstandard encoding names that we do support (for now).
+
+2017-11-08  Maciej Stachowiak  <[email protected]>
+
         Switch encoding WPT test suite to updating via import-w3c-tests
         https://bugs.webkit.org/show_bug.cgi?id=179412
 

Added: trunk/LayoutTests/fast/encoding/legacy-ios-encodings-expected.txt (0 => 224589)


--- trunk/LayoutTests/fast/encoding/legacy-ios-encodings-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/encoding/legacy-ios-encodings-expected.txt	2017-11-08 19:35:18 UTC (rev 224589)
@@ -0,0 +1,36 @@
+This test verifies that certain legacy iOS text encodings are not supported.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+The following encodings should not be supported
+PASS new TextDecoder("macos-6-10.2").encoding threw exception RangeError: Bad value.
+PASS new TextDecoder("macos-6_2-10.4").encoding threw exception RangeError: Bad value.
+PASS new TextDecoder("macos-35-10.2").encoding threw exception RangeError: Bad value.
+PASS new TextDecoder("macos-29-10.2").encoding threw exception RangeError: Bad value.
+PASS new TextDecoder("macos-7_3-10.2").encoding threw exception RangeError: Bad value.
+The following encoding names are supported by WebKit cross-platform, but some may be removed at a later time.
+PASS new TextDecoder("x-mac-greek").encoding is "x-mac-greek"
+PASS new TextDecoder("windows-10006").encoding is "x-mac-greek"
+PASS new TextDecoder("macgr").encoding is "x-mac-greek"
+PASS new TextDecoder("x-macgreek").encoding is "x-mac-greek"
+PASS new TextDecoder("x-mac-turkish").encoding is "x-mac-turkish"
+PASS new TextDecoder("windows-10081").encoding is "x-mac-turkish"
+PASS new TextDecoder("mactr").encoding is "x-mac-turkish"
+PASS new TextDecoder("x-macturkish").encoding is "x-mac-turkish"
+PASS new TextDecoder("x-mac-centraleurroman").encoding is "x-mac-centraleurroman"
+PASS new TextDecoder("windows-10029").encoding is "x-mac-centraleurroman"
+PASS new TextDecoder("x-mac-ce").encoding is "x-mac-centraleurroman"
+PASS new TextDecoder("macce").encoding is "x-mac-centraleurroman"
+PASS new TextDecoder("maccentraleurope").encoding is "x-mac-centraleurroman"
+PASS new TextDecoder("x-maccentraleurope").encoding is "x-mac-centraleurroman"
+PASS new TextDecoder("x-mac-cyrillic").encoding is "x-mac-cyrillic"
+PASS new TextDecoder("windows-10007").encoding is "x-mac-cyrillic"
+PASS new TextDecoder("mac-cyrillic").encoding is "x-mac-cyrillic"
+PASS new TextDecoder("maccy").encoding is "x-mac-cyrillic"
+PASS new TextDecoder("x-maccyrillic").encoding is "x-mac-cyrillic"
+PASS new TextDecoder("x-macukraine").encoding is "x-mac-cyrillic"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/encoding/legacy-ios-encodings.html (0 => 224589)


--- trunk/LayoutTests/fast/encoding/legacy-ios-encodings.html	                        (rev 0)
+++ trunk/LayoutTests/fast/encoding/legacy-ios-encodings.html	2017-11-08 19:35:18 UTC (rev 224589)
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<script src=""
+</head>
+<body>
+<script>
+description("This test verifies that certain legacy iOS text encodings are not supported.");
+
+debug("The following encodings should not be supported");
+let iosLegacyEncodings = ['macos-6-10.2','macos-6_2-10.4', 'macos-35-10.2', 'macos-29-10.2', 'macos-7_3-10.2'];
+
+for (let encoding of iosLegacyEncodings) {
+    let canonical_name_expr = 'new TextDecoder("' + encoding + '").encoding';
+    shouldThrow(canonical_name_expr);
+}
+
+
+
+debug("The following encoding names are supported by WebKit cross-platform, but some may be removed at a later time.");
+let validForNow = [
+    {encoding: 'x-mac-greek', aliases: ['x-mac-greek', 'windows-10006', 'macgr', 'x-macgreek']},
+    {encoding: 'x-mac-turkish', aliases: ['x-mac-turkish', 'windows-10081', 'mactr', 'x-macturkish']},
+    {encoding: 'x-mac-centraleurroman', aliases: ['x-mac-centraleurroman', 'windows-10029', 'x-mac-ce', 'macce', 'maccentraleurope', 'x-maccentraleurope']},
+    {encoding: 'x-mac-cyrillic', aliases: ['x-mac-cyrillic', 'windows-10007', 'mac-cyrillic', 'maccy', 'x-maccyrillic', 'x-macukraine']}
+];
+
+for (let encoding of validForNow) {
+    for (let alias of encoding.aliases) {
+         let canonical_name_expr = 'new TextDecoder("' + alias + '").encoding';
+         shouldBe(canonical_name_expr, '"' + encoding.encoding + '"');
+    }
+}
+
+
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (224588 => 224589)


--- trunk/Source/WebCore/ChangeLog	2017-11-08 19:30:36 UTC (rev 224588)
+++ trunk/Source/WebCore/ChangeLog	2017-11-08 19:35:18 UTC (rev 224589)
@@ -1,3 +1,17 @@
+2017-11-08  Maciej Stachowiak  <[email protected]>
+
+        iOS supports some text encodings supposedly due to lack of TEC that aren't supported by the TEC decoder on macOS
+        https://bugs.webkit.org/show_bug.cgi?id=179309
+
+        Reviewed by Darin Adler.
+
+        Test: fast/encoding/legacy-ios-encodings.html
+
+        * platform/text/TextCodecICU.cpp:
+        (WebCore::TextCodecICU::registerEncodingNames): Remove most iOS-specific adding of names, leaving only softbank-sjis. 
+        Most were either redundant or unnecessary.
+        (WebCore::TextCodecICU::registerCodecs): ditto
+
 2017-11-08  Zan Dobersek  <[email protected]>
 
         Unreviewed. Attempting to unbork the WinCairo bot after r224578.

Modified: trunk/Source/WebCore/platform/text/TextCodecICU.cpp (224588 => 224589)


--- trunk/Source/WebCore/platform/text/TextCodecICU.cpp	2017-11-08 19:30:36 UTC (rev 224588)
+++ trunk/Source/WebCore/platform/text/TextCodecICU.cpp	2017-11-08 19:35:18 UTC (rev 224589)
@@ -43,18 +43,6 @@
 
 const size_t ConversionBufferSize = 16384;
 
-#if PLATFORM(IOS)
-static const char* textCodecMacAliases[] = {
-    "macos-7_3-10.2", // xmaccyrillic, maccyrillic
-    "macos-6_2-10.4", // xmacgreek
-    "macos-6-10.2",   // macgreek
-    "macos-29-10.2",  // xmaccentraleurroman, maccentraleurroman
-    "macos-35-10.2",  // xmacturkish, macturkish
-    "softbank-sjis",  // softbanksjis
-    nullptr
-};
-#endif
-
 ICUConverterWrapper::~ICUConverterWrapper()
 {
     if (converter)
@@ -182,26 +170,8 @@
     }
 
 #if PLATFORM(IOS)
-    // A.B. adding a few more Mac encodings missing 'cause we don't have TextCodecMac right now
-    // luckily, they are supported in ICU, just need to alias them.
-    // this handles encodings that OS X uses TEC (TextCodecMac)
-    // <http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/index.jsp?topic=/com.ibm.etools.mft.eb.doc/ac00408_.htm>
-    int32_t i = 0;
-    for (const char* macAlias = textCodecMacAliases[i]; macAlias; macAlias = textCodecMacAliases[++i]) {
-        registrar(macAlias, macAlias);
-
-        UErrorCode error = U_ZERO_ERROR;
-        uint16_t numAliases = ucnv_countAliases(macAlias, &error);
-        ASSERT(U_SUCCESS(error));
-        if (U_SUCCESS(error))
-            for (uint16_t j = 0; j < numAliases; ++j) {
-                error = U_ZERO_ERROR;
-                const char* alias = ucnv_getAlias(macAlias, j, &error);
-                ASSERT(U_SUCCESS(error));
-                if (U_SUCCESS(error) && strcmp(alias, macAlias))
-                    registrar(alias, macAlias);
-            }
-    }
+    // FIXME: This may not be needed any more. <https://bugs.webkit.org/show_bug.cgi?id=179416>
+    registrar("softbank-sjis", "softbank-sjis");
 #endif
 }
 
@@ -246,10 +216,8 @@
     }
 
 #if PLATFORM(IOS)
-    // See comment above in registerEncodingNames().
-    int32_t i = 0;
-    for (const char* alias = textCodecMacAliases[i]; alias; alias = textCodecMacAliases[++i])
-        registrar(alias, create, 0);
+    // FIXME: This may not be needed any more. <https://bugs.webkit.org/show_bug.cgi?id=179416>
+    registrar("softbank-sjis", create, 0);
 #endif
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to