ICU 75.1 75.1
Loading...
Searching...
No Matches
uspoof.h
Go to the documentation of this file.
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
3/*
4***************************************************************************
5* Copyright (C) 2008-2016, International Business Machines Corporation
6* and others. All Rights Reserved.
7***************************************************************************
8* file name: uspoof.h
9* encoding: UTF-8
10* tab size: 8 (not used)
11* indentation:4
12*
13* created on: 2008Feb13
14* created by: Andy Heninger
15*
16* Unicode Spoof Detection
17*/
18
19#ifndef USPOOF_H
20#define USPOOF_H
21
22#include "unicode/ubidi.h"
23#include "unicode/utypes.h"
24#include "unicode/uset.h"
25#include "unicode/parseerr.h"
26
27#if !UCONFIG_NO_NORMALIZATION
28
29
30#if U_SHOW_CPLUSPLUS_API
32#include "unicode/unistr.h"
33#include "unicode/uniset.h"
34#endif
35
36
422
423struct USpoofChecker;
429struct USpoofCheckResult;
435
443typedef enum USpoofChecks {
453
463
473
484
485#ifndef U_HIDE_DEPRECATED_API
492#endif /* U_HIDE_DEPRECATED_API */
493
508
509#ifndef U_HIDE_DEPRECATED_API
516#endif /* U_HIDE_DEPRECATED_API */
517
525
532
540
561
568
581 USPOOF_AUX_INFO = 0x40000000
582
584
585
595 typedef enum URestrictionLevel {
602 USPOOF_ASCII = 0x10000000,
650#ifndef U_HIDE_INTERNAL_API
656#endif /* U_HIDE_INTERNAL_API */
658
669U_CAPI USpoofChecker * U_EXPORT2
671
672
694U_CAPI USpoofChecker * U_EXPORT2
695uspoof_openFromSerialized(const void *data, int32_t length, int32_t *pActualLength,
696 UErrorCode *pErrorCode);
697
728U_CAPI USpoofChecker * U_EXPORT2
729uspoof_openFromSource(const char *confusables, int32_t confusablesLen,
730 const char *confusablesWholeScript, int32_t confusablesWholeScriptLen,
731 int32_t *errType, UParseError *pe, UErrorCode *status);
732
733
739U_CAPI void U_EXPORT2
741
751U_CAPI USpoofChecker * U_EXPORT2
753
754
795U_CAPI void U_EXPORT2
796uspoof_setChecks(USpoofChecker *sc, int32_t checks, UErrorCode *status);
797
809U_CAPI int32_t U_EXPORT2
811
823U_CAPI void U_EXPORT2
825
826
836
879U_CAPI void U_EXPORT2
880uspoof_setAllowedLocales(USpoofChecker *sc, const char *localesList, UErrorCode *status);
881
903U_CAPI const char * U_EXPORT2
905
906
925U_CAPI void U_EXPORT2
927
928
949U_CAPI const USet * U_EXPORT2
951
952
985U_CAPI int32_t U_EXPORT2
987 const UChar *id, int32_t length,
988 int32_t *position,
989 UErrorCode *status);
990
991
1024U_CAPI int32_t U_EXPORT2
1026 const char *id, int32_t length,
1027 int32_t *position,
1028 UErrorCode *status);
1029
1030
1059U_CAPI int32_t U_EXPORT2
1061 const UChar* id, int32_t length,
1062 USpoofCheckResult* checkResult,
1063 UErrorCode *status);
1064
1096U_CAPI int32_t U_EXPORT2
1098 const char *id, int32_t length,
1099 USpoofCheckResult* checkResult,
1100 UErrorCode *status);
1101
1120U_CAPI USpoofCheckResult* U_EXPORT2
1122
1130U_CAPI void U_EXPORT2
1132
1147U_CAPI int32_t U_EXPORT2
1149
1160U_CAPI URestrictionLevel U_EXPORT2
1162
1174U_CAPI const USet* U_EXPORT2
1176
1177
1221U_CAPI int32_t U_EXPORT2
1223 const UChar *id1, int32_t length1,
1224 const UChar *id2, int32_t length2,
1225 UErrorCode *status);
1226
1227#ifndef U_HIDE_DRAFT_API
1274U_CAPI uint32_t U_EXPORT2 uspoof_areBidiConfusable(const USpoofChecker *sc, UBiDiDirection direction,
1275 const UChar *id1, int32_t length1,
1276 const UChar *id2, int32_t length2,
1277 UErrorCode *status);
1278#endif /* U_HIDE_DRAFT_API */
1279
1305U_CAPI int32_t U_EXPORT2
1307 const char *id1, int32_t length1,
1308 const char *id2, int32_t length2,
1309 UErrorCode *status);
1310
1311#ifndef U_HIDE_DRAFT_API
1339U_CAPI uint32_t U_EXPORT2 uspoof_areBidiConfusableUTF8(const USpoofChecker *sc, UBiDiDirection direction,
1340 const char *id1, int32_t length1,
1341 const char *id2, int32_t length2,
1342 UErrorCode *status);
1343#endif /* U_HIDE_DRAFT_API */
1344
1376U_CAPI int32_t U_EXPORT2
1378 uint32_t type,
1379 const UChar *id, int32_t length,
1380 UChar *dest, int32_t destCapacity,
1381 UErrorCode *status);
1382
1383#ifndef U_HIDE_DRAFT_API
1416U_CAPI int32_t U_EXPORT2 uspoof_getBidiSkeleton(const USpoofChecker *sc,
1417 UBiDiDirection direction,
1418 const UChar *id, int32_t length,
1419 UChar *dest, int32_t destCapacity, UErrorCode *status);
1420#endif /* U_HIDE_DRAFT_API */
1421
1455U_CAPI int32_t U_EXPORT2
1457 uint32_t type,
1458 const char *id, int32_t length,
1459 char *dest, int32_t destCapacity,
1460 UErrorCode *status);
1461
1462#ifndef U_HIDE_DRAFT_API
1497U_CAPI int32_t U_EXPORT2 uspoof_getBidiSkeletonUTF8(const USpoofChecker *sc, UBiDiDirection direction,
1498 const char *id, int32_t length, char *dest,
1499 int32_t destCapacity, UErrorCode *status);
1500#endif /* U_HIDE_DRAFT_API */
1501
1514U_CAPI const USet * U_EXPORT2
1516
1529U_CAPI const USet * U_EXPORT2
1531
1554U_CAPI int32_t U_EXPORT2
1556 void *data, int32_t capacity,
1557 UErrorCode *status);
1558
1560
1561#if U_SHOW_CPLUSPLUS_API
1562
1563U_NAMESPACE_BEGIN
1564
1600U_NAMESPACE_END
1601
1620U_CAPI void U_EXPORT2
1622
1623
1644U_CAPI const icu::UnicodeSet * U_EXPORT2
1646
1675U_CAPI int32_t U_EXPORT2
1677 const icu::UnicodeString &id,
1678 int32_t *position,
1679 UErrorCode *status);
1680
1706U_CAPI int32_t U_EXPORT2
1708 const icu::UnicodeString &id,
1709 USpoofCheckResult* checkResult,
1710 UErrorCode *status);
1711
1733U_CAPI int32_t U_EXPORT2
1735 const icu::UnicodeString &s1,
1736 const icu::UnicodeString &s2,
1737 UErrorCode *status);
1738
1739#ifndef U_HIDE_DRAFT_API
1764 UBiDiDirection direction,
1765 const icu::UnicodeString &s1,
1766 const icu::UnicodeString &s2,
1767 UErrorCode *status);
1768#endif /* U_HIDE_DRAFT_API */
1769
1795 uint32_t type,
1796 const icu::UnicodeString &id,
1797 icu::UnicodeString &dest,
1798 UErrorCode *status);
1799
1800#ifndef U_HIDE_DRAFT_API
1826 const USpoofChecker *sc, UBiDiDirection direction, const icu::UnicodeString &id,
1827 icu::UnicodeString &dest, UErrorCode *status);
1828#endif /* U_HIDE_DRAFT_API */
1829
1842U_CAPI const icu::UnicodeSet * U_EXPORT2
1844
1857U_CAPI const icu::UnicodeSet * U_EXPORT2
1859
1860#endif /* U_SHOW_CPLUSPLUS_API */
1861
1862#endif /* UCONFIG_NO_NORMALIZATION */
1863
1864#endif /* USPOOF_H */
"Smart pointer" class, closes a USpoofCheckResult via uspoof_closeCheckResult().
"Smart pointer" class, closes a USpoofChecker via uspoof_close().
A mutable set of Unicode characters and multicharacter strings.
Definition uniset.h:285
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:296
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
C API: Parse Error Information.
A UParseError struct is used to returned detailed information about parsing errors.
Definition parseerr.h:58
C API: Bidi algorithm.
UBiDiDirection
UBiDiDirection values indicate the text direction.
Definition ubidi.h:429
#define U_CDECL_END
This is used to end a declaration of a library private ICU C API.
Definition umachine.h:86
#define U_CAPI
This is used to declare a function as a public ICU C API.
Definition umachine.h:110
char16_t UChar
The base type for UTF-16 code units and pointers.
Definition umachine.h:378
#define U_CDECL_BEGIN
This is used to begin a declaration of a library private ICU C API.
Definition umachine.h:85
C++ API: Unicode Set.
C++ API: Unicode String.
C API: Unicode Set.
struct USet USet
USet is the C API type corresponding to C++ class UnicodeSet.
Definition uset.h:50
U_CAPI const USet * uspoof_getRecommendedSet(UErrorCode *status)
Get the set of characters from Recommended Scripts for Inclusion in Identifiers, as defined in http:/...
U_CAPI void uspoof_setChecks(USpoofChecker *sc, int32_t checks, UErrorCode *status)
Specify the bitmask of checks that will be performed by uspoof_check.
USpoofChecks
Enum for the kinds of checks that USpoofChecker can perform.
Definition uspoof.h:443
@ USPOOF_MIXED_NUMBERS
Check that an identifier does not mix numbers from different numbering systems.
Definition uspoof.h:539
@ USPOOF_RESTRICTION_LEVEL
Check that an identifier is no looser than the specified RestrictionLevel.
Definition uspoof.h:507
@ USPOOF_CHAR_LIMIT
Check that an identifier contains only characters from a specified set of acceptable characters.
Definition uspoof.h:531
@ USPOOF_CONFUSABLE
Enable this flag in uspoof_setChecks to turn on all types of confusables.
Definition uspoof.h:483
@ USPOOF_ALL_CHECKS
Enable all spoof checks.
Definition uspoof.h:567
@ USPOOF_SINGLE_SCRIPT
Check that an identifier contains only characters from a single script (plus chars from the common an...
Definition uspoof.h:515
@ USPOOF_HIDDEN_OVERLAY
Check that an identifier does not have a combining character following a character in which that comb...
Definition uspoof.h:560
@ USPOOF_INVISIBLE
Check an identifier for the presence of invisible characters, such as zero-width spaces,...
Definition uspoof.h:524
@ USPOOF_MIXED_SCRIPT_CONFUSABLE
When performing the two-string uspoof_areConfusable test, this flag in the return value indicates tha...
Definition uspoof.h:462
@ USPOOF_AUX_INFO
Enable the return of auxiliary (non-error) information in the upper bits of the check results value.
Definition uspoof.h:581
@ USPOOF_WHOLE_SCRIPT_CONFUSABLE
When performing the two-string uspoof_areConfusable test, this flag in the return value indicates tha...
Definition uspoof.h:472
@ USPOOF_SINGLE_SCRIPT_CONFUSABLE
When performing the two-string uspoof_areConfusable test, this flag in the return value indicates tha...
Definition uspoof.h:452
@ USPOOF_ANY_CASE
This flag is deprecated and no longer affects the behavior of SpoofChecker.
Definition uspoof.h:491
U_CAPI int32_t uspoof_serialize(USpoofChecker *sc, void *data, int32_t capacity, UErrorCode *status)
Serialize the data for a spoof detector into a chunk of memory.
U_CAPI const USet * uspoof_getCheckResultNumerics(const USpoofCheckResult *checkResult, UErrorCode *status)
Gets the set of numerics found in the string, if the USPOOF_MIXED_NUMBERS check was enabled; otherwis...
U_CAPI void uspoof_setAllowedChars(USpoofChecker *sc, const USet *chars, UErrorCode *status)
Limit the acceptable characters to those specified by a Unicode Set.
U_CAPI int32_t uspoof_areConfusableUTF8(const USpoofChecker *sc, const char *id1, int32_t length1, const char *id2, int32_t length2, UErrorCode *status)
A version of uspoof_areConfusable accepting strings in UTF-8 format.
U_CAPI USpoofChecker * uspoof_openFromSerialized(const void *data, int32_t length, int32_t *pActualLength, UErrorCode *pErrorCode)
Open a Spoof checker from its serialized form, stored in 32-bit-aligned memory.
U_CAPI int32_t uspoof_checkUTF8(const USpoofChecker *sc, const char *id, int32_t length, int32_t *position, UErrorCode *status)
Check the specified string for possible security issues.
U_CAPI USpoofCheckResult * uspoof_openCheckResult(UErrorCode *status)
Create a USpoofCheckResult, used by the uspoof_check2 class of functions to return information about ...
U_CAPI uint32_t uspoof_areBidiConfusable(const USpoofChecker *sc, UBiDiDirection direction, const UChar *id1, int32_t length1, const UChar *id2, int32_t length2, UErrorCode *status)
Check whether two specified strings are visually confusable when displayed in a context with the give...
U_I18N_API icu::UnicodeString & uspoof_getSkeletonUnicodeString(const USpoofChecker *sc, uint32_t type, const icu::UnicodeString &id, icu::UnicodeString &dest, UErrorCode *status)
Get the "skeleton" for an identifier.
U_CAPI const icu::UnicodeSet * uspoof_getRecommendedUnicodeSet(UErrorCode *status)
Get the set of characters from Recommended Scripts for Inclusion in Identifiers, as defined in http:/...
URestrictionLevel
Constants from UTS #39 for use in uspoof_setRestrictionLevel, and for returned identifier restriction...
Definition uspoof.h:595
@ USPOOF_SINGLE_SCRIPT_RESTRICTIVE
The string classifies as ASCII-Only, or all characters in the string are in the identifier profile an...
Definition uspoof.h:609
@ USPOOF_MODERATELY_RESTRICTIVE
The string classifies as Highly Restrictive, or all characters in the string are in the identifier pr...
Definition uspoof.h:631
@ USPOOF_ASCII
All characters in the string are in the identifier profile and all characters in the string are in th...
Definition uspoof.h:602
@ USPOOF_UNDEFINED_RESTRICTIVE
An undefined restriction level.
Definition uspoof.h:655
@ USPOOF_RESTRICTION_LEVEL_MASK
Mask for selecting the Restriction Level bits from the return value of uspoof_check.
Definition uspoof.h:649
@ USPOOF_MINIMALLY_RESTRICTIVE
All characters in the string are in the identifier profile.
Definition uspoof.h:637
@ USPOOF_HIGHLY_RESTRICTIVE
The string classifies as Single Script, or all characters in the string are in the identifier profile...
Definition uspoof.h:623
@ USPOOF_UNRESTRICTIVE
Any valid identifiers, including characters outside of the Identifier Profile.
Definition uspoof.h:643
U_CAPI int32_t uspoof_getSkeletonUTF8(const USpoofChecker *sc, uint32_t type, const char *id, int32_t length, char *dest, int32_t destCapacity, UErrorCode *status)
Get the "skeleton" for an identifier.
U_CAPI USpoofChecker * uspoof_clone(const USpoofChecker *sc, UErrorCode *status)
Clone a Spoof Checker.
U_CAPI int32_t uspoof_checkUnicodeString(const USpoofChecker *sc, const icu::UnicodeString &id, int32_t *position, UErrorCode *status)
Check the specified string for possible security issues.
U_CAPI int32_t uspoof_check2(const USpoofChecker *sc, const UChar *id, int32_t length, USpoofCheckResult *checkResult, UErrorCode *status)
Check the specified string for possible security issues.
U_CAPI int32_t uspoof_getBidiSkeletonUTF8(const USpoofChecker *sc, UBiDiDirection direction, const char *id, int32_t length, char *dest, int32_t destCapacity, UErrorCode *status)
Get the "bidiSkeleton" for an identifier and a direction.
U_CAPI int32_t uspoof_getCheckResultChecks(const USpoofCheckResult *checkResult, UErrorCode *status)
Indicates which of the spoof check(s) have failed.
U_CAPI int32_t uspoof_getChecks(const USpoofChecker *sc, UErrorCode *status)
Get the set of checks that this Spoof Checker has been configured to perform.
U_CAPI void uspoof_setAllowedLocales(USpoofChecker *sc, const char *localesList, UErrorCode *status)
Limit characters that are acceptable in identifiers being checked to those normally used with the lan...
U_CAPI void uspoof_setAllowedUnicodeSet(USpoofChecker *sc, const icu::UnicodeSet *chars, UErrorCode *status)
Limit the acceptable characters to those specified by a Unicode Set.
U_CAPI USpoofChecker * uspoof_openFromSource(const char *confusables, int32_t confusablesLen, const char *confusablesWholeScript, int32_t confusablesWholeScriptLen, int32_t *errType, UParseError *pe, UErrorCode *status)
Open a Spoof Checker from the source form of the spoof data.
U_CAPI const char * uspoof_getAllowedLocales(USpoofChecker *sc, UErrorCode *status)
Get a list of locales for the scripts that are acceptable in strings to be checked.
U_CAPI const icu::UnicodeSet * uspoof_getInclusionUnicodeSet(UErrorCode *status)
Get the set of Candidate Characters for Inclusion in Identifiers, as defined in http://unicode....
U_CAPI int32_t uspoof_check(const USpoofChecker *sc, const UChar *id, int32_t length, int32_t *position, UErrorCode *status)
Check the specified string for possible security issues.
U_CAPI int32_t uspoof_areConfusableUnicodeString(const USpoofChecker *sc, const icu::UnicodeString &s1, const icu::UnicodeString &s2, UErrorCode *status)
A version of uspoof_areConfusable accepting UnicodeStrings.
U_CAPI const icu::UnicodeSet * uspoof_getAllowedUnicodeSet(const USpoofChecker *sc, UErrorCode *status)
Get a UnicodeSet for the characters permitted in an identifier.
U_CAPI USpoofChecker * uspoof_open(UErrorCode *status)
Create a Unicode Spoof Checker, configured to perform all checks except for USPOOF_LOCALE_LIMIT and U...
U_I18N_API icu::UnicodeString & uspoof_getBidiSkeletonUnicodeString(const USpoofChecker *sc, UBiDiDirection direction, const icu::UnicodeString &id, icu::UnicodeString &dest, UErrorCode *status)
Get the "bidiSkeleton" for an identifier and a direction.
struct USpoofCheckResult USpoofCheckResult
Definition uspoof.h:434
U_CAPI int32_t uspoof_check2UnicodeString(const USpoofChecker *sc, const icu::UnicodeString &id, USpoofCheckResult *checkResult, UErrorCode *status)
Check the specified string for possible security issues.
U_CAPI const USet * uspoof_getInclusionSet(UErrorCode *status)
Get the set of Candidate Characters for Inclusion in Identifiers, as defined in http://unicode....
U_CAPI const USet * uspoof_getAllowedChars(const USpoofChecker *sc, UErrorCode *status)
Get a USet for the characters permitted in an identifier.
U_CAPI uint32_t uspoof_areBidiConfusableUnicodeString(const USpoofChecker *sc, UBiDiDirection direction, const icu::UnicodeString &s1, const icu::UnicodeString &s2, UErrorCode *status)
A version of uspoof_areBidiConfusable accepting UnicodeStrings.
U_CAPI void uspoof_closeCheckResult(USpoofCheckResult *checkResult)
Close a USpoofCheckResult, freeing any memory that was being held by its implementation.
struct USpoofChecker USpoofChecker
typedef for C of USpoofChecker
Definition uspoof.h:427
U_CAPI uint32_t uspoof_areBidiConfusableUTF8(const USpoofChecker *sc, UBiDiDirection direction, const char *id1, int32_t length1, const char *id2, int32_t length2, UErrorCode *status)
A version of uspoof_areBidiConfusable accepting strings in UTF-8 format.
U_CAPI int32_t uspoof_getSkeleton(const USpoofChecker *sc, uint32_t type, const UChar *id, int32_t length, UChar *dest, int32_t destCapacity, UErrorCode *status)
Get the "skeleton" for an identifier.
U_CAPI URestrictionLevel uspoof_getCheckResultRestrictionLevel(const USpoofCheckResult *checkResult, UErrorCode *status)
Gets the restriction level that the text meets, if the USPOOF_RESTRICTION_LEVEL check was enabled; ot...
U_CAPI int32_t uspoof_check2UTF8(const USpoofChecker *sc, const char *id, int32_t length, USpoofCheckResult *checkResult, UErrorCode *status)
Check the specified string for possible security issues.
U_CAPI int32_t uspoof_areConfusable(const USpoofChecker *sc, const UChar *id1, int32_t length1, const UChar *id2, int32_t length2, UErrorCode *status)
Check whether two specified strings are visually confusable.
U_CAPI void uspoof_close(USpoofChecker *sc)
Close a Spoof Checker, freeing any memory that was being held by its implementation.
U_CAPI void uspoof_setRestrictionLevel(USpoofChecker *sc, URestrictionLevel restrictionLevel)
Set the loosest restriction level allowed for strings.
U_CAPI int32_t uspoof_getBidiSkeleton(const USpoofChecker *sc, UBiDiDirection direction, const UChar *id, int32_t length, UChar *dest, int32_t destCapacity, UErrorCode *status)
Get the "bidiSkeleton" for an identifier and a direction.
U_CAPI URestrictionLevel uspoof_getRestrictionLevel(const USpoofChecker *sc)
Get the Restriction Level that will be tested if the checks include USPOOF_RESTRICTION_LEVEL.
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:415
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition utypes.h:301