summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshane <shane@svn.icu-project.org>2016-10-28 17:56:22 +0000
committerFredrik Roubert <roubert@google.com>2016-12-15 18:51:47 +0100
commit30d72325ff801226a0b11c4770dcc822ca47dff3 (patch)
tree4b46487e761e0e6d8292c994e28445ed2e1591fe
parent448279191e6d5f155a9f9dde4212c14e69ee1b6b (diff)
downloadandroid_external_icu-30d72325ff801226a0b11c4770dcc822ca47dff3.tar.gz
android_external_icu-30d72325ff801226a0b11c4770dcc822ca47dff3.tar.bz2
android_external_icu-30d72325ff801226a0b11c4770dcc822ca47dff3.zip
Cherry-pick: ticket:12825 Fixing icu4c spoof checker issues #12825 and #12815.
http://bugs.icu-project.org/trac/changeset/39493 Change-Id: I83dd6fe8c80bdb9f9bb2b29c71447534d1f4e111
-rw-r--r--icu4c/source/i18n/scriptset.cpp2
-rw-r--r--icu4c/source/i18n/uspoof.cpp7
-rw-r--r--icu4c/source/test/intltest/itspoof.cpp25
-rw-r--r--icu4c/source/test/intltest/itspoof.h4
4 files changed, 30 insertions, 8 deletions
diff --git a/icu4c/source/i18n/scriptset.cpp b/icu4c/source/i18n/scriptset.cpp
index 5a425352d..ff853b84e 100644
--- a/icu4c/source/i18n/scriptset.cpp
+++ b/icu4c/source/i18n/scriptset.cpp
@@ -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) {
diff --git a/icu4c/source/i18n/uspoof.cpp b/icu4c/source/i18n/uspoof.cpp
index 9cb41e2c9..febaddc94 100644
--- a/icu4c/source/i18n/uspoof.cpp
+++ b/icu4c/source/i18n/uspoof.cpp
@@ -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);
diff --git a/icu4c/source/test/intltest/itspoof.cpp b/icu4c/source/test/intltest/itspoof.cpp
index 835ef22e7..06b68dbc2 100644
--- a/icu4c/source/test/intltest/itspoof.cpp
+++ b/icu4c/source/test/intltest/itspoof.cpp
@@ -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 */
diff --git a/icu4c/source/test/intltest/itspoof.h b/icu4c/source/test/intltest/itspoof.h
index fc54e89a0..354003f10 100644
--- a/icu4c/source/test/intltest/itspoof.h
+++ b/icu4c/source/test/intltest/itspoof.h
@@ -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);