]> granicus.if.org Git - icu/commitdiff
ICU-13021 Disallow grouping separators in exponential patterns.
authorShane Carr <shane@unicode.org>
Thu, 14 Sep 2017 00:35:08 +0000 (00:35 +0000)
committerShane Carr <shane@unicode.org>
Thu, 14 Sep 2017 00:35:08 +0000 (00:35 +0000)
X-SVN-Rev: 40411

icu4j/main/classes/core/src/com/ibm/icu/impl/number/PatternStringParser.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/number/PatternStringTest.java

index 1bf8d5e62c6847fbb43888a01426d9bde20d4a9d..853ed1dd5686ef4f6416338df4c5c3b58ea20611 100644 (file)
@@ -484,6 +484,9 @@ public class PatternStringParser {
         if (state.peek() != 'E') {
             return;
         }
+        if ((result.groupingSizes & 0xffff0000L) != 0xffff0000L) {
+            throw state.toParseException("Cannot have grouping separator in scientific notation");
+        }
         state.next(); // consume the E
         result.widthExceptAffixes++;
         if (state.peek() == '+') {
index aabf06adb0ef748871e24906b92704a363927240..b0979839862a7426e35ca7d8b29a8a800ab14334 100644 (file)
@@ -46,7 +46,6 @@ public class PatternStringTest {
       {"0E0", "0E0"},
       {"#00E00", "#00E00"},
       {"#,##0", "#,##0"},
-      {"#,##0E0", "#,##0E0"},
       {"#;#", "0;0"},
       {"#;-#", "0"}, // ignore a negative prefix pattern of '-' since that is the default
       {"**##0", "**##0"},
@@ -99,7 +98,7 @@ public class PatternStringTest {
   @Test
   public void testExceptionOnInvalid() {
     String[] invalidPatterns = {
-      "#.#.#", "0#", "0#.", ".#0", "0#.#0", "@0", "0@", "0,", "0,,", "0,,0", "0,,0,"
+      "#.#.#", "0#", "0#.", ".#0", "0#.#0", "@0", "0@", "0,", "0,,", "0,,0", "0,,0,", "#,##0E0"
     };
 
     for (String pattern : invalidPatterns) {