LEFT | RIGHT |
1 // © 2016 and later: Unicode, Inc. and others. | 1 // © 2016 and later: Unicode, Inc. and others. |
2 // License & terms of use: http://www.unicode.org/copyright.html | 2 // License & terms of use: http://www.unicode.org/copyright.html |
3 /* | 3 /* |
4 ********************************************************************** | 4 ********************************************************************** |
5 * Copyright (C) 2008-2016, International Business Machines | 5 * Copyright (C) 2008-2016, International Business Machines |
6 * Corporation and others. All Rights Reserved. | 6 * Corporation and others. All Rights Reserved. |
7 ********************************************************************** | 7 ********************************************************************** |
8 */ | 8 */ |
9 | 9 |
10 #include "unicode/utypes.h" | 10 #include "unicode/utypes.h" |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 && !resolvedNoLatn.test(USCRIPT_CYRILLIC, status) | 370 && !resolvedNoLatn.test(USCRIPT_CYRILLIC, status) |
371 && !resolvedNoLatn.test(USCRIPT_GREEK, status) | 371 && !resolvedNoLatn.test(USCRIPT_GREEK, status) |
372 && !resolvedNoLatn.test(USCRIPT_CHEROKEE, status)) { | 372 && !resolvedNoLatn.test(USCRIPT_CHEROKEE, status)) { |
373 return USPOOF_MODERATELY_RESTRICTIVE; | 373 return USPOOF_MODERATELY_RESTRICTIVE; |
374 } | 374 } |
375 | 375 |
376 // Section 5.2 step 8: | 376 // Section 5.2 step 8: |
377 return USPOOF_MINIMALLY_RESTRICTIVE; | 377 return USPOOF_MINIMALLY_RESTRICTIVE; |
378 } | 378 } |
379 | 379 |
380 int32_t SpoofImpl::findIllegalCombiningDot(const UnicodeString& input, UErrorCod
e&) const { | 380 int32_t SpoofImpl::findHiddenOverlay(const UnicodeString& input, UErrorCode&) co
nst { |
381 bool sawLeadCharacter = false; | 381 bool sawLeadCharacter = false; |
382 for (int32_t i=0; i<input.length();) { | 382 for (int32_t i=0; i<input.length();) { |
383 UChar32 cp = input.char32At(i); | 383 UChar32 cp = input.char32At(i); |
384 if (sawLeadCharacter && cp == 0x0307) { | 384 if (sawLeadCharacter && cp == 0x0307) { |
385 return i; | 385 return i; |
386 } | 386 } |
387 sawLeadCharacter = isIllegalCombiningDotLeadCharacter(cp); | 387 uint8_t combiningClass = u_getCombiningClass(cp); |
| 388 // Skip over characters except for those with combining class 0 (non-com
bining characters) or with |
| 389 // combining class 230 (same class as U+0307) |
| 390 U_ASSERT(u_getCombiningClass(0x0307) == 230); |
| 391 if (combiningClass == 0 || combiningClass == 230) { |
| 392 sawLeadCharacter = isIllegalCombiningDotLeadCharacter(cp); |
| 393 } |
388 i += U16_LENGTH(cp); | 394 i += U16_LENGTH(cp); |
389 } | 395 } |
390 return -1; | 396 return -1; |
391 } | 397 } |
392 | 398 |
393 static inline bool isIllegalCombiningDotLeadCharacterNoLookup(UChar32 cp) { | 399 static inline bool isIllegalCombiningDotLeadCharacterNoLookup(UChar32 cp) { |
394 return cp == u'i' || cp == u'j' || cp == u'ȷ' || cp == u'l' || | 400 return cp == u'i' || cp == u'j' || cp == u'ı' || cp == u'ȷ' || cp == u'l' || |
395 u_hasBinaryProperty(cp, UCHAR_SOFT_DOTTED); | 401 u_hasBinaryProperty(cp, UCHAR_SOFT_DOTTED); |
396 } | 402 } |
397 | 403 |
398 bool SpoofImpl::isIllegalCombiningDotLeadCharacter(UChar32 cp) const { | 404 bool SpoofImpl::isIllegalCombiningDotLeadCharacter(UChar32 cp) const { |
399 if (isIllegalCombiningDotLeadCharacterNoLookup(cp)) { | 405 if (isIllegalCombiningDotLeadCharacterNoLookup(cp)) { |
400 return true; | 406 return true; |
401 } | 407 } |
402 UnicodeString skelStr; | 408 UnicodeString skelStr; |
403 fSpoofData->confusableLookup(cp, skelStr); | 409 fSpoofData->confusableLookup(cp, skelStr); |
404 UChar32 cp1 = skelStr.char32At(0); | 410 UChar32 finalCp = skelStr.char32At(skelStr.moveIndex32(skelStr.length(), -1)
); |
405 if (skelStr.countChar32() == 1 && cp1 != cp && isIllegalCombiningDotLeadChar
acterNoLookup(cp1)) { | 411 if (finalCp != cp && isIllegalCombiningDotLeadCharacterNoLookup(finalCp)) { |
406 return true; | 412 return true; |
407 } | 413 } |
408 return false; | 414 return false; |
409 } | 415 } |
410 | 416 |
411 | 417 |
412 | 418 |
413 // Convert a text format hex number. Utility function used by builder code. St
atic. | 419 // Convert a text format hex number. Utility function used by builder code. St
atic. |
414 // Input: UChar *string text. Output: a UChar32 | 420 // Input: UChar *string text. Output: a UChar32 |
415 // Input has been pre-checked, and will have no non-hex chars. | 421 // Input has been pre-checked, and will have no non-hex chars. |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 } | 971 } |
966 // swap starting at fLength | 972 // swap starting at fLength |
967 ds->swapArray32(ds, &spoofDH->fLength, sizeof(SpoofDataHeader)-8 /* minus ma
gic and fFormatVersion[4] */, &outputDH->fLength, status); | 973 ds->swapArray32(ds, &spoofDH->fLength, sizeof(SpoofDataHeader)-8 /* minus ma
gic and fFormatVersion[4] */, &outputDH->fLength, status); |
968 | 974 |
969 return totalSize; | 975 return totalSize; |
970 } | 976 } |
971 | 977 |
972 #endif | 978 #endif |
973 | 979 |
974 | 980 |
LEFT | RIGHT |