Bug 1382656 - Don't search for multiple Unicode extension sequences in a single language tag. r=till
authorAndré Bargull <andre.bargull@gmail.com>
Fri, 28 Jul 2017 12:56:53 -0700
changeset 371906 820435b8583623782455b7f18e84b1a1b568e2ab
parent 371905 3bceabbf445d41049258415796c2961a04b7ef9d
child 371907 e1ec4e403b9d6326fe38f51be3422790df8deb22
push id47611
push userarchaeopteryx@coole-files.de
push dateSun, 30 Jul 2017 09:20:48 +0000
treeherderautoland@8b577b152383 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstill
bugs1382656
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1382656 - Don't search for multiple Unicode extension sequences in a single language tag. r=till
js/src/builtin/Intl.js
--- a/js/src/builtin/Intl.js
+++ b/js/src/builtin/Intl.js
@@ -102,21 +102,21 @@ function removeUnicodeExtensions(locale)
     // the concatenation.
     var pos = callFunction(std_String_indexOf, locale, "-x-");
     if (pos < 0)
         pos = locale.length;
 
     var left = callFunction(String_substring, locale, 0, pos);
     var right = callFunction(String_substring, locale, pos);
 
-    var extensions;
     var unicodeLocaleExtensionSequenceRE = getUnicodeLocaleExtensionSequenceRE();
-    while ((extensions = regexp_exec_no_statics(unicodeLocaleExtensionSequenceRE, left)) !== null) {
-        left = StringReplaceString(left, extensions[0], "");
-        unicodeLocaleExtensionSequenceRE.lastIndex = 0;
+    var extensions = regexp_exec_no_statics(unicodeLocaleExtensionSequenceRE, left);
+    if (extensions !== null) {
+        left = callFunction(String_substring, left, 0, extensions.index) +
+               callFunction(String_substring, left, extensions.index + extensions[0].length);
     }
 
     var combined = left + right;
     assert(IsStructurallyValidLanguageTag(combined), "recombination produced an invalid language tag");
     assert(function() {
         var uindex = callFunction(std_String_indexOf, combined, "-u-");
         if (uindex < 0)
             return true;