Title: [205568] trunk
Revision
205568
Author
commit-qu...@webkit.org
Date
2016-09-07 15:01:39 -0700 (Wed, 07 Sep 2016)

Log Message

[INTL] some valid language tags cause errors in Intl constructors
https://bugs.webkit.org/show_bug.cgi?id=161672

Patch by Andy VanWagoner <thetalecraf...@gmail.com> on 2016-09-07
Reviewed by Mark Lam.

Source/_javascript_Core:

Fix private use tag parsing to match spec, allowing single character parts.
https://www.rfc-editor.org/rfc/bcp/bcp47.txt

```
privateuse    = "x" 1*("-" (1*8alphanum))
```

* runtime/IntlObject.cpp:
(JSC::privateUseLangTag): Allow singleton parts in private use tag.

LayoutTests:

Add list of valid language tags that should not throw from test262.

* js/intl-collator-expected.txt:
* js/intl-datetimeformat-expected.txt:
* js/intl-numberformat-expected.txt:
* js/script-tests/intl-collator.js:
* js/script-tests/intl-datetimeformat.js:
* js/script-tests/intl-numberformat.js:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (205567 => 205568)


--- trunk/LayoutTests/ChangeLog	2016-09-07 21:17:27 UTC (rev 205567)
+++ trunk/LayoutTests/ChangeLog	2016-09-07 22:01:39 UTC (rev 205568)
@@ -1,3 +1,19 @@
+2016-09-07  Andy VanWagoner  <thetalecraf...@gmail.com>
+
+        [INTL] some valid language tags cause errors in Intl constructors
+        https://bugs.webkit.org/show_bug.cgi?id=161672
+
+        Reviewed by Mark Lam.
+
+        Add list of valid language tags that should not throw from test262.
+
+        * js/intl-collator-expected.txt:
+        * js/intl-datetimeformat-expected.txt:
+        * js/intl-numberformat-expected.txt:
+        * js/script-tests/intl-collator.js:
+        * js/script-tests/intl-datetimeformat.js:
+        * js/script-tests/intl-numberformat.js:
+
 2016-09-07  Chris Dumez  <cdu...@apple.com>
 
         Drop legacy canvas.probablySupportsContext()

Modified: trunk/LayoutTests/js/intl-collator-expected.txt (205567 => 205568)


--- trunk/LayoutTests/js/intl-collator-expected.txt	2016-09-07 21:17:27 UTC (rev 205567)
+++ trunk/LayoutTests/js/intl-collator-expected.txt	2016-09-07 22:01:39 UTC (rev 205568)
@@ -106,6 +106,25 @@
 PASS Intl.Collator.supportedLocalesOf('en-*') threw exception RangeError: invalid language tag: en-*.
 PASS Intl.Collator.supportedLocalesOf('en-') threw exception RangeError: invalid language tag: en-.
 PASS Intl.Collator.supportedLocalesOf('en--US') threw exception RangeError: invalid language tag: en--US.
+PASS Intl.Collator.supportedLocalesOf('de') did not throw exception.
+PASS Intl.Collator.supportedLocalesOf('de-DE') did not throw exception.
+PASS Intl.Collator.supportedLocalesOf('DE-de') did not throw exception.
+PASS Intl.Collator.supportedLocalesOf('cmn') did not throw exception.
+PASS Intl.Collator.supportedLocalesOf('cmn-Hans') did not throw exception.
+PASS Intl.Collator.supportedLocalesOf('CMN-hANS') did not throw exception.
+PASS Intl.Collator.supportedLocalesOf('cmn-hans-cn') did not throw exception.
+PASS Intl.Collator.supportedLocalesOf('es-419') did not throw exception.
+PASS Intl.Collator.supportedLocalesOf('es-419-u-nu-latn-cu-bob') did not throw exception.
+PASS Intl.Collator.supportedLocalesOf('i-klingon') did not throw exception.
+PASS Intl.Collator.supportedLocalesOf('cmn-hans-cn-t-ca-u-ca-x-t-u') did not throw exception.
+PASS Intl.Collator.supportedLocalesOf('enochian-enochian') did not throw exception.
+PASS Intl.Collator.supportedLocalesOf('de-gregory-u-ca-gregory') did not throw exception.
+PASS Intl.Collator.supportedLocalesOf('aa-a-foo-x-a-foo-bar') did not throw exception.
+PASS Intl.Collator.supportedLocalesOf('x-en-US-12345') did not throw exception.
+PASS Intl.Collator.supportedLocalesOf('x-12345-12345-en-US') did not throw exception.
+PASS Intl.Collator.supportedLocalesOf('x-en-US-12345-12345') did not throw exception.
+PASS Intl.Collator.supportedLocalesOf('x-en-u-foo') did not throw exception.
+PASS Intl.Collator.supportedLocalesOf('x-en-u-foo-u-bar') did not throw exception.
 PASS Intl.Collator.prototype.constructor is Intl.Collator
 PASS Intl.Collator.prototype.compare is an instance of Function
 PASS Object.getOwnPropertyDescriptor(Intl.Collator.prototype, 'compare').get is an instance of Function

Modified: trunk/LayoutTests/js/intl-datetimeformat-expected.txt (205567 => 205568)


--- trunk/LayoutTests/js/intl-datetimeformat-expected.txt	2016-09-07 21:17:27 UTC (rev 205567)
+++ trunk/LayoutTests/js/intl-datetimeformat-expected.txt	2016-09-07 22:01:39 UTC (rev 205568)
@@ -43,6 +43,25 @@
 PASS Intl.DateTimeFormat.supportedLocalesOf('en-*') threw exception RangeError: invalid language tag: en-*.
 PASS Intl.DateTimeFormat.supportedLocalesOf('en-') threw exception RangeError: invalid language tag: en-.
 PASS Intl.DateTimeFormat.supportedLocalesOf('en--US') threw exception RangeError: invalid language tag: en--US.
+PASS Intl.DateTimeFormat.supportedLocalesOf('de') did not throw exception.
+PASS Intl.DateTimeFormat.supportedLocalesOf('de-DE') did not throw exception.
+PASS Intl.DateTimeFormat.supportedLocalesOf('DE-de') did not throw exception.
+PASS Intl.DateTimeFormat.supportedLocalesOf('cmn') did not throw exception.
+PASS Intl.DateTimeFormat.supportedLocalesOf('cmn-Hans') did not throw exception.
+PASS Intl.DateTimeFormat.supportedLocalesOf('CMN-hANS') did not throw exception.
+PASS Intl.DateTimeFormat.supportedLocalesOf('cmn-hans-cn') did not throw exception.
+PASS Intl.DateTimeFormat.supportedLocalesOf('es-419') did not throw exception.
+PASS Intl.DateTimeFormat.supportedLocalesOf('es-419-u-nu-latn-cu-bob') did not throw exception.
+PASS Intl.DateTimeFormat.supportedLocalesOf('i-klingon') did not throw exception.
+PASS Intl.DateTimeFormat.supportedLocalesOf('cmn-hans-cn-t-ca-u-ca-x-t-u') did not throw exception.
+PASS Intl.DateTimeFormat.supportedLocalesOf('enochian-enochian') did not throw exception.
+PASS Intl.DateTimeFormat.supportedLocalesOf('de-gregory-u-ca-gregory') did not throw exception.
+PASS Intl.DateTimeFormat.supportedLocalesOf('aa-a-foo-x-a-foo-bar') did not throw exception.
+PASS Intl.DateTimeFormat.supportedLocalesOf('x-en-US-12345') did not throw exception.
+PASS Intl.DateTimeFormat.supportedLocalesOf('x-12345-12345-en-US') did not throw exception.
+PASS Intl.DateTimeFormat.supportedLocalesOf('x-en-US-12345-12345') did not throw exception.
+PASS Intl.DateTimeFormat.supportedLocalesOf('x-en-u-foo') did not throw exception.
+PASS Intl.DateTimeFormat.supportedLocalesOf('x-en-u-foo-u-bar') did not throw exception.
 PASS Intl.DateTimeFormat.prototype.constructor is Intl.DateTimeFormat
 PASS Intl.DateTimeFormat.prototype.format is an instance of Function
 PASS Object.getOwnPropertyDescriptor(Intl.DateTimeFormat.prototype, 'format').get is an instance of Function

Modified: trunk/LayoutTests/js/intl-numberformat-expected.txt (205567 => 205568)


--- trunk/LayoutTests/js/intl-numberformat-expected.txt	2016-09-07 21:17:27 UTC (rev 205567)
+++ trunk/LayoutTests/js/intl-numberformat-expected.txt	2016-09-07 22:01:39 UTC (rev 205568)
@@ -111,6 +111,25 @@
 PASS Intl.NumberFormat.supportedLocalesOf('en-*') threw exception RangeError: invalid language tag: en-*.
 PASS Intl.NumberFormat.supportedLocalesOf('en-') threw exception RangeError: invalid language tag: en-.
 PASS Intl.NumberFormat.supportedLocalesOf('en--US') threw exception RangeError: invalid language tag: en--US.
+PASS Intl.NumberFormat.supportedLocalesOf('de') did not throw exception.
+PASS Intl.NumberFormat.supportedLocalesOf('de-DE') did not throw exception.
+PASS Intl.NumberFormat.supportedLocalesOf('DE-de') did not throw exception.
+PASS Intl.NumberFormat.supportedLocalesOf('cmn') did not throw exception.
+PASS Intl.NumberFormat.supportedLocalesOf('cmn-Hans') did not throw exception.
+PASS Intl.NumberFormat.supportedLocalesOf('CMN-hANS') did not throw exception.
+PASS Intl.NumberFormat.supportedLocalesOf('cmn-hans-cn') did not throw exception.
+PASS Intl.NumberFormat.supportedLocalesOf('es-419') did not throw exception.
+PASS Intl.NumberFormat.supportedLocalesOf('es-419-u-nu-latn-cu-bob') did not throw exception.
+PASS Intl.NumberFormat.supportedLocalesOf('i-klingon') did not throw exception.
+PASS Intl.NumberFormat.supportedLocalesOf('cmn-hans-cn-t-ca-u-ca-x-t-u') did not throw exception.
+PASS Intl.NumberFormat.supportedLocalesOf('enochian-enochian') did not throw exception.
+PASS Intl.NumberFormat.supportedLocalesOf('de-gregory-u-ca-gregory') did not throw exception.
+PASS Intl.NumberFormat.supportedLocalesOf('aa-a-foo-x-a-foo-bar') did not throw exception.
+PASS Intl.NumberFormat.supportedLocalesOf('x-en-US-12345') did not throw exception.
+PASS Intl.NumberFormat.supportedLocalesOf('x-12345-12345-en-US') did not throw exception.
+PASS Intl.NumberFormat.supportedLocalesOf('x-en-US-12345-12345') did not throw exception.
+PASS Intl.NumberFormat.supportedLocalesOf('x-en-u-foo') did not throw exception.
+PASS Intl.NumberFormat.supportedLocalesOf('x-en-u-foo-u-bar') did not throw exception.
 PASS Intl.NumberFormat.prototype.constructor is Intl.NumberFormat
 PASS Intl.NumberFormat.prototype.format is an instance of Function
 PASS Object.getOwnPropertyDescriptor(Intl.NumberFormat.prototype, 'format').get is an instance of Function

Modified: trunk/LayoutTests/js/script-tests/intl-collator.js (205567 => 205568)


--- trunk/LayoutTests/js/script-tests/intl-collator.js	2016-09-07 21:17:27 UTC (rev 205567)
+++ trunk/LayoutTests/js/script-tests/intl-collator.js	2016-09-07 22:01:39 UTC (rev 205568)
@@ -179,6 +179,31 @@
 shouldThrow("Intl.Collator.supportedLocalesOf('en-*')", "'RangeError: invalid language tag: en-*'");
 shouldThrow("Intl.Collator.supportedLocalesOf('en-')", "'RangeError: invalid language tag: en-'");
 shouldThrow("Intl.Collator.supportedLocalesOf('en--US')", "'RangeError: invalid language tag: en--US'");
+// Accepts valid tags
+var validLanguageTags = [
+    "de", // ISO 639 language code
+    "de-DE", // + ISO 3166-1 country code
+    "DE-de", // tags are case-insensitive
+    "cmn", // ISO 639 language code
+    "cmn-Hans", // + script code
+    "CMN-hANS", // tags are case-insensitive
+    "cmn-hans-cn", // + ISO 3166-1 country code
+    "es-419", // + UN M.49 region code
+    "es-419-u-nu-latn-cu-bob", // + Unicode locale extension sequence
+    "i-klingon", // grandfathered tag
+    "cmn-hans-cn-t-ca-u-ca-x-t-u", // singleton subtags can also be used as private use subtags
+    "enochian-enochian", // language and variant subtags may be the same
+    "de-gregory-u-ca-gregory", // variant and extension subtags may be the same
+    "aa-a-foo-x-a-foo-bar", // variant subtags can also be used as private use subtags
+    "x-en-US-12345", // anything goes in private use tags
+    "x-12345-12345-en-US",
+    "x-en-US-12345-12345",
+    "x-en-u-foo",
+    "x-en-u-foo-u-bar"
+];
+for (var validLanguageTag of validLanguageTags) {
+    shouldNotThrow("Intl.Collator.supportedLocalesOf('" + validLanguageTag + "')");
+}
 
 // 10.3 Properties of the Intl.Collator Prototype Object
 

Modified: trunk/LayoutTests/js/script-tests/intl-datetimeformat.js (205567 => 205568)


--- trunk/LayoutTests/js/script-tests/intl-datetimeformat.js	2016-09-07 21:17:27 UTC (rev 205567)
+++ trunk/LayoutTests/js/script-tests/intl-datetimeformat.js	2016-09-07 22:01:39 UTC (rev 205568)
@@ -73,6 +73,31 @@
 shouldThrow("Intl.DateTimeFormat.supportedLocalesOf('en-*')", "'RangeError: invalid language tag: en-*'");
 shouldThrow("Intl.DateTimeFormat.supportedLocalesOf('en-')", "'RangeError: invalid language tag: en-'");
 shouldThrow("Intl.DateTimeFormat.supportedLocalesOf('en--US')", "'RangeError: invalid language tag: en--US'");
+// Accepts valid tags
+var validLanguageTags = [
+    "de", // ISO 639 language code
+    "de-DE", // + ISO 3166-1 country code
+    "DE-de", // tags are case-insensitive
+    "cmn", // ISO 639 language code
+    "cmn-Hans", // + script code
+    "CMN-hANS", // tags are case-insensitive
+    "cmn-hans-cn", // + ISO 3166-1 country code
+    "es-419", // + UN M.49 region code
+    "es-419-u-nu-latn-cu-bob", // + Unicode locale extension sequence
+    "i-klingon", // grandfathered tag
+    "cmn-hans-cn-t-ca-u-ca-x-t-u", // singleton subtags can also be used as private use subtags
+    "enochian-enochian", // language and variant subtags may be the same
+    "de-gregory-u-ca-gregory", // variant and extension subtags may be the same
+    "aa-a-foo-x-a-foo-bar", // variant subtags can also be used as private use subtags
+    "x-en-US-12345", // anything goes in private use tags
+    "x-12345-12345-en-US",
+    "x-en-US-12345-12345",
+    "x-en-u-foo",
+    "x-en-u-foo-u-bar"
+];
+for (var validLanguageTag of validLanguageTags) {
+    shouldNotThrow("Intl.DateTimeFormat.supportedLocalesOf('" + validLanguageTag + "')");
+}
 
 // 12.3 Properties of the Intl.DateTimeFormat Prototype Object
 

Modified: trunk/LayoutTests/js/script-tests/intl-numberformat.js (205567 => 205568)


--- trunk/LayoutTests/js/script-tests/intl-numberformat.js	2016-09-07 21:17:27 UTC (rev 205567)
+++ trunk/LayoutTests/js/script-tests/intl-numberformat.js	2016-09-07 22:01:39 UTC (rev 205568)
@@ -189,6 +189,31 @@
 shouldThrow("Intl.NumberFormat.supportedLocalesOf('en-*')", "'RangeError: invalid language tag: en-*'");
 shouldThrow("Intl.NumberFormat.supportedLocalesOf('en-')", "'RangeError: invalid language tag: en-'");
 shouldThrow("Intl.NumberFormat.supportedLocalesOf('en--US')", "'RangeError: invalid language tag: en--US'");
+// Accepts valid tags
+var validLanguageTags = [
+    "de", // ISO 639 language code
+    "de-DE", // + ISO 3166-1 country code
+    "DE-de", // tags are case-insensitive
+    "cmn", // ISO 639 language code
+    "cmn-Hans", // + script code
+    "CMN-hANS", // tags are case-insensitive
+    "cmn-hans-cn", // + ISO 3166-1 country code
+    "es-419", // + UN M.49 region code
+    "es-419-u-nu-latn-cu-bob", // + Unicode locale extension sequence
+    "i-klingon", // grandfathered tag
+    "cmn-hans-cn-t-ca-u-ca-x-t-u", // singleton subtags can also be used as private use subtags
+    "enochian-enochian", // language and variant subtags may be the same
+    "de-gregory-u-ca-gregory", // variant and extension subtags may be the same
+    "aa-a-foo-x-a-foo-bar", // variant subtags can also be used as private use subtags
+    "x-en-US-12345", // anything goes in private use tags
+    "x-12345-12345-en-US",
+    "x-en-US-12345-12345",
+    "x-en-u-foo",
+    "x-en-u-foo-u-bar"
+];
+for (var validLanguageTag of validLanguageTags) {
+    shouldNotThrow("Intl.NumberFormat.supportedLocalesOf('" + validLanguageTag + "')");
+}
 
 // 11.3 Properties of the Intl.NumberFormat Prototype Object
 

Modified: trunk/Source/_javascript_Core/ChangeLog (205567 => 205568)


--- trunk/Source/_javascript_Core/ChangeLog	2016-09-07 21:17:27 UTC (rev 205567)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-09-07 22:01:39 UTC (rev 205568)
@@ -1,3 +1,20 @@
+2016-09-07  Andy VanWagoner  <thetalecraf...@gmail.com>
+
+        [INTL] some valid language tags cause errors in Intl constructors
+        https://bugs.webkit.org/show_bug.cgi?id=161672
+
+        Reviewed by Mark Lam.
+
+        Fix private use tag parsing to match spec, allowing single character parts.
+        https://www.rfc-editor.org/rfc/bcp/bcp47.txt
+
+        ```
+        privateuse    = "x" 1*("-" (1*8alphanum))
+        ```
+
+        * runtime/IntlObject.cpp:
+        (JSC::privateUseLangTag): Allow singleton parts in private use tag.
+
 2016-09-07  Benjamin Poulain  <bpoul...@apple.com>
 
         [JSC] Remove a couple of useless forward declaration

Modified: trunk/Source/_javascript_Core/runtime/IntlObject.cpp (205567 => 205568)


--- trunk/Source/_javascript_Core/runtime/IntlObject.cpp	2016-09-07 21:17:27 UTC (rev 205567)
+++ trunk/Source/_javascript_Core/runtime/IntlObject.cpp	2016-09-07 22:01:39 UTC (rev 205568)
@@ -258,7 +258,7 @@
     size_t currentIndex = startIndex;
 
     // Check for privateuse.
-    // privateuse = "x" 1*("-" (2*8alphanum))
+    // privateuse = "x" 1*("-" (1*8alphanum))
     StringBuilder privateuse;
     while (currentIndex < numParts) {
         const String& singleton = parts[currentIndex];
@@ -277,7 +277,7 @@
             const String& extPart = parts[currentIndex];
             unsigned extPartLength = extPart.length();
 
-            bool isValid = (extPartLength >= 2 && extPartLength <= 8 && extPart.isAllSpecialCharacters<isASCIIAlphanumeric>());
+            bool isValid = (extPartLength >= 1 && extPartLength <= 8 && extPart.isAllSpecialCharacters<isASCIIAlphanumeric>());
             if (!isValid)
                 break;
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to