]> granicus.if.org Git - icu/commitdiff
ICU-12825 Fixing icu4c spoof checker issues #12825 and #12815.
authorShane Carr <shane@unicode.org>
Fri, 28 Oct 2016 17:56:22 +0000 (17:56 +0000)
committerShane Carr <shane@unicode.org>
Fri, 28 Oct 2016 17:56:22 +0000 (17:56 +0000)
X-SVN-Rev: 39493

icu4c/source/i18n/scriptset.cpp
icu4c/source/i18n/uspoof.cpp
icu4c/source/test/intltest/itspoof.cpp
icu4c/source/test/intltest/itspoof.h

index 5a425352d9996b843408738ecbdaf3ca9735fc78..ff853b84e3a11bf7d88f8290ca3eabf8eba9e858 100644 (file)
@@ -258,7 +258,7 @@ void ScriptSet::setScriptExtensions(UChar32 codePoint, UErrorCode& status) {
 
     while (TRUE) {
         script_count = uscript_getScriptExtensions(
-            codePoint, scripts.getAlias(), FIRST_GUESS_SCRIPT_CAPACITY, &internalStatus);
+            codePoint, scripts.getAlias(), scripts.getCapacity(), &internalStatus);
         if (internalStatus == U_BUFFER_OVERFLOW_ERROR) {
             // Need to allocate more space
             if (scripts.resize(script_count) == NULL) {
index 9cb41e2c9f7eba04b0c533745e2d105e17fe51d2..febaddc94994fcef84e53f5af2690dbd174da65e 100644 (file)
@@ -646,13 +646,6 @@ uspoof_getSkeletonUnicodeString(const USpoofChecker *sc,
         return dest;
     }
 
-    // Check that at least one of the CONFUSABLE flags is turned on.  If not,
-    // return an error.
-    if ((This->fChecks & USPOOF_CONFUSABLE) == 0) {
-        *status = U_ILLEGAL_ARGUMENT_ERROR;
-        return dest;
-    }
-
     UnicodeString nfdId;
     gNfdNormalizer->normalize(id, nfdId, *status);
 
index 835ef22e7423f306e935879f1daaae481f95a6c0..06b68dbc25c85c480a7c87bade7ac29e4a79b31d 100644 (file)
@@ -88,6 +88,8 @@ void IntlTestSpoof::runIndexedTest( int32_t index, UBool exec, const char* &name
     TESTCASE_AUTO(testRestrictionLevel);
     TESTCASE_AUTO(testMixedNumbers);
     TESTCASE_AUTO(testBug12153);
+    TESTCASE_AUTO(testBug12825);
+    TESTCASE_AUTO(testBug12815);
     TESTCASE_AUTO_END;
 }
 
@@ -657,4 +659,27 @@ void IntlTestSpoof::testBug12153() {
     TEST_ASSERT_SUCCESS(status);
 }
 
+// uspoof_checkUnicodeString should NOT have an infinite loop.
+void IntlTestSpoof::testBug12825() {
+    UErrorCode status = U_ZERO_ERROR;
+    LocalUSpoofCheckerPointer sc(uspoof_open(&status));
+    TEST_ASSERT_SUCCESS(status);
+    uspoof_setChecks(sc.getAlias(), USPOOF_ALL_CHECKS | USPOOF_AUX_INFO, &status);
+    TEST_ASSERT_SUCCESS(status);
+    uspoof_checkUnicodeString(sc.getAlias(), UnicodeString("\\u30FB").unescape(), NULL, &status);
+    TEST_ASSERT_SUCCESS(status);
+}
+
+// uspoof_getSkeleton should NOT set an ILLEGAL_ARGUMENT_EXCEPTION.
+void IntlTestSpoof::testBug12815() {
+    UErrorCode status = U_ZERO_ERROR;
+    LocalUSpoofCheckerPointer sc(uspoof_open(&status));
+    TEST_ASSERT_SUCCESS(status);
+    uspoof_setChecks(sc.getAlias(), USPOOF_RESTRICTION_LEVEL, &status);
+    TEST_ASSERT_SUCCESS(status);
+    UnicodeString result;
+    uspoof_getSkeletonUnicodeString(sc.getAlias(), 0, UnicodeString("hello world"), result, &status);
+    TEST_ASSERT_SUCCESS(status);
+}
+
 #endif /* !UCONFIG_NO_REGULAR_EXPRESSIONS && !UCONFIG_NO_NORMALIZATION && !UCONFIG_NO_FILE_IO */
index fc54e89a0ac13dc941677d5a5a5a1c92cff33bd7..354003f10c0c4eac929e1b22dfcd414c7de5a031 100644 (file)
@@ -46,6 +46,10 @@ public:
 
     void testBug12153();
 
+    void testBug12825();
+
+    void testBug12815();
+
     // Internal function to run a single skeleton test case.
     void  checkSkeleton(const USpoofChecker *sc, uint32_t flags, 
                         const char *input, const char *expected, int32_t lineNum);