From ed528c7b3a5b01a8da03609a6e72d9d5cd791aea Mon Sep 17 00:00:00 2001 From: Alan Liu Date: Wed, 24 May 2000 18:25:27 +0000 Subject: [PATCH] ICU-352 disallow bad ranges X-SVN-Rev: 1458 --- icu4c/source/i18n/uniset.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/icu4c/source/i18n/uniset.cpp b/icu4c/source/i18n/uniset.cpp index b55ca3028d..c57f85261d 100644 --- a/icu4c/source/i18n/uniset.cpp +++ b/icu4c/source/i18n/uniset.cpp @@ -703,6 +703,14 @@ UnicodeString& UnicodeSet::parse(UnicodeString& pairsBuf /*result*/, } else if (lastOp == 0 && !isLiteral && (c == HYPHEN || c == INTERSECTION)) { lastOp = c; } else if (lastOp == HYPHEN) { + if (lastChar >= c) { + // Don't allow redundant (a-a) or empty (b-a) ranges; + // these are most likely typos. + //throw new IllegalArgumentException("Invalid range " + lastChar + + // '-' + c); + status = U_ILLEGAL_ARGUMENT_ERROR; + return pairsBuf; + } addPair(pairsBuf, (UChar)lastChar, c); lastOp = 0; lastChar = -1;