IntlObject.cpp::removeUnicodeLocaleExtension() should not touch locales that end...
authorrmorisset@apple.com <rmorisset@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 May 2018 15:47:29 +0000 (15:47 +0000)
committerrmorisset@apple.com <rmorisset@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 May 2018 15:47:29 +0000 (15:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=185162

Reviewed by Filip Pizlo.

JSTests:

* stress/incomplete-unicode-locale.js: Added.
(catch):

Source/JavaScriptCore:

* runtime/IntlObject.cpp:
(JSC::removeUnicodeLocaleExtension):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231196 268f45cc-cd09-0410-ab3c-d52691b4dbfc

JSTests/ChangeLog
JSTests/stress/incomplete-unicode-locale.js [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/IntlObject.cpp

index 73e00d8..f880379 100644 (file)
@@ -1,3 +1,13 @@
+2018-05-01  Robin Morisset  <rmorisset@apple.com>
+
+        IntlObject.cpp::removeUnicodeLocaleExtension() should not touch locales that end in '-u'
+        https://bugs.webkit.org/show_bug.cgi?id=185162
+
+        Reviewed by Filip Pizlo.
+
+        * stress/incomplete-unicode-locale.js: Added.
+        (catch):
+
 2018-05-01  Dominik Infuehr  <dinfuehr@igalia.com>
 
         Add SetCallee as DFG-Operation
diff --git a/JSTests/stress/incomplete-unicode-locale.js b/JSTests/stress/incomplete-unicode-locale.js
new file mode 100644 (file)
index 0000000..c96be83
--- /dev/null
@@ -0,0 +1,3 @@
+try {
+    new Intl.NumberFormat("en-x-u");
+} catch (e) {}
index e4a3635..b51b635 100644 (file)
@@ -1,3 +1,13 @@
+2018-05-01  Robin Morisset  <rmorisset@apple.com>
+
+        IntlObject.cpp::removeUnicodeLocaleExtension() should not touch locales that end in '-u'
+        https://bugs.webkit.org/show_bug.cgi?id=185162
+
+        Reviewed by Filip Pizlo.
+
+        * runtime/IntlObject.cpp:
+        (JSC::removeUnicodeLocaleExtension):
+
 2018-05-01  Dominik Infuehr  <dinfuehr@igalia.com>
 
         Add SetCallee as DFG-Operation
index 2b4c07f..4a7f6de 100644 (file)
@@ -614,7 +614,7 @@ String removeUnicodeLocaleExtension(const String& locale)
     if (partsSize > 0)
         builder.append(parts[0]);
     for (size_t p = 1; p < partsSize; ++p) {
-        if (parts[p] == "u") {
+        if (parts[p] == "u" && p + 1 < partsSize) {
             // Skip the u- and anything that follows until another singleton.
             // While the next part is part of the unicode extension, skip it.
             while (p + 1 < partsSize && parts[p + 1].length() > 1)