ICU 66.1 66.1
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/utypes.h"
23#include "unicode/uset.h"
24#include "unicode/parseerr.h"
26
27#if !UCONFIG_NO_NORMALIZATION
28
29
30#if U_SHOW_CPLUSPLUS_API
31#include "unicode/unistr.h"
32#include "unicode/uniset.h"
33#endif
34
35
357
358struct USpoofChecker;
364struct USpoofCheckResult;
370
378typedef enum USpoofChecks {
388
398
408
419
420#ifndef U_HIDE_DEPRECATED_API
427#endif /* U_HIDE_DEPRECATED_API */
428
443
444#ifndef U_HIDE_DEPRECATED_API
451#endif /* U_HIDE_DEPRECATED_API */
452
460
467
475
496
503
516 USPOOF_AUX_INFO = 0x40000000
517
519
520
530 typedef enum URestrictionLevel {
537 USPOOF_ASCII = 0x10000000,
585#ifndef U_HIDE_INTERNAL_API
591#endif /* U_HIDE_INTERNAL_API */
593
604U_STABLE USpoofChecker * U_EXPORT2
606
607
629U_STABLE USpoofChecker * U_EXPORT2
630uspoof_openFromSerialized(const void *data, int32_t length, int32_t *pActualLength,
631 UErrorCode *pErrorCode);
632
663U_STABLE USpoofChecker * U_EXPORT2
664uspoof_openFromSource(const char *confusables, int32_t confusablesLen,
665 const char *confusablesWholeScript, int32_t confusablesWholeScriptLen,
666 int32_t *errType, UParseError *pe, UErrorCode *status);
667
668
674U_STABLE void U_EXPORT2
676
686U_STABLE USpoofChecker * U_EXPORT2
688
689
727U_STABLE void U_EXPORT2
728uspoof_setChecks(USpoofChecker *sc, int32_t checks, UErrorCode *status);
729
741U_STABLE int32_t U_EXPORT2
743
755U_STABLE void U_EXPORT2
757
758
768
811U_STABLE void U_EXPORT2
812uspoof_setAllowedLocales(USpoofChecker *sc, const char *localesList, UErrorCode *status);
813
835U_STABLE const char * U_EXPORT2
837
838
857U_STABLE void U_EXPORT2
859
860
881U_STABLE const USet * U_EXPORT2
883
884
917U_STABLE int32_t U_EXPORT2
919 const UChar *id, int32_t length,
920 int32_t *position,
921 UErrorCode *status);
922
923
956U_STABLE int32_t U_EXPORT2
958 const char *id, int32_t length,
959 int32_t *position,
960 UErrorCode *status);
961
962
991U_STABLE int32_t U_EXPORT2
993 const UChar* id, int32_t length,
994 USpoofCheckResult* checkResult,
995 UErrorCode *status);
996
1028U_STABLE int32_t U_EXPORT2
1030 const char *id, int32_t length,
1031 USpoofCheckResult* checkResult,
1032 UErrorCode *status);
1033
1052U_STABLE USpoofCheckResult* U_EXPORT2
1054
1062U_STABLE void U_EXPORT2
1064
1079U_STABLE int32_t U_EXPORT2
1081
1094
1106U_STABLE const USet* U_EXPORT2
1108
1109
1153U_STABLE int32_t U_EXPORT2
1155 const UChar *id1, int32_t length1,
1156 const UChar *id2, int32_t length2,
1157 UErrorCode *status);
1158
1159
1160
1186U_STABLE int32_t U_EXPORT2
1188 const char *id1, int32_t length1,
1189 const char *id2, int32_t length2,
1190 UErrorCode *status);
1191
1192
1193
1194
1226U_STABLE int32_t U_EXPORT2
1228 uint32_t type,
1229 const UChar *id, int32_t length,
1230 UChar *dest, int32_t destCapacity,
1231 UErrorCode *status);
1232
1266U_STABLE int32_t U_EXPORT2
1268 uint32_t type,
1269 const char *id, int32_t length,
1270 char *dest, int32_t destCapacity,
1271 UErrorCode *status);
1272
1285U_STABLE const USet * U_EXPORT2
1287
1300U_STABLE const USet * U_EXPORT2
1302
1325U_STABLE int32_t U_EXPORT2
1327 void *data, int32_t capacity,
1328 UErrorCode *status);
1329
1331
1332#if U_SHOW_CPLUSPLUS_API
1333
1334U_NAMESPACE_BEGIN
1335
1371U_NAMESPACE_END
1372
1391U_STABLE void U_EXPORT2
1393
1394
1415U_STABLE const icu::UnicodeSet * U_EXPORT2
1417
1446U_STABLE int32_t U_EXPORT2
1448 const icu::UnicodeString &id,
1449 int32_t *position,
1450 UErrorCode *status);
1451
1477U_STABLE int32_t U_EXPORT2
1479 const icu::UnicodeString &id,
1480 USpoofCheckResult* checkResult,
1481 UErrorCode *status);
1482
1504U_STABLE int32_t U_EXPORT2
1506 const icu::UnicodeString &s1,
1507 const icu::UnicodeString &s2,
1508 UErrorCode *status);
1509
1535 uint32_t type,
1536 const icu::UnicodeString &id,
1537 icu::UnicodeString &dest,
1538 UErrorCode *status);
1539
1552U_STABLE const icu::UnicodeSet * U_EXPORT2
1554
1567U_STABLE const icu::UnicodeSet * U_EXPORT2
1569
1570#endif /* U_SHOW_CPLUSPLUS_API */
1571
1572#endif /* UCONFIG_NO_NORMALIZATION */
1573
1574#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:281
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:295
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.
Definition: localpointer.h:562
C API: Parse Error Information.
A UParseError struct is used to returned detailed information about parsing errors.
Definition: parseerr.h:58
#define U_CDECL_END
This is used to end a declaration of a library private ICU C API.
Definition: umachine.h:85
uint16_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:84
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition: umachine.h:111
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:47
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.
USpoofCheckResult * uspoof_openCheckResult(UErrorCode *status)
Create a USpoofCheckResult, used by the uspoof_check2 class of functions to return information about ...
USpoofChecks
Enum for the kinds of checks that USpoofChecker can perform.
Definition: uspoof.h:378
@ USPOOF_MIXED_NUMBERS
Check that an identifier does not mix numbers from different numbering systems.
Definition: uspoof.h:474
@ USPOOF_RESTRICTION_LEVEL
Check that an identifier is no looser than the specified RestrictionLevel.
Definition: uspoof.h:442
@ USPOOF_CHAR_LIMIT
Check that an identifier contains only characters from a specified set of acceptable characters.
Definition: uspoof.h:466
@ USPOOF_CONFUSABLE
Enable this flag in uspoof_setChecks to turn on all types of confusables.
Definition: uspoof.h:418
@ USPOOF_ALL_CHECKS
Enable all spoof checks.
Definition: uspoof.h:502
@ USPOOF_SINGLE_SCRIPT
Check that an identifier contains only characters from a single script (plus chars from the common an...
Definition: uspoof.h:450
@ USPOOF_HIDDEN_OVERLAY
Check that an identifier does not have a combining character following a character in which that comb...
Definition: uspoof.h:495
@ USPOOF_INVISIBLE
Check an identifier for the presence of invisible characters, such as zero-width spaces,...
Definition: uspoof.h:459
@ USPOOF_MIXED_SCRIPT_CONFUSABLE
When performing the two-string uspoof_areConfusable test, this flag in the return value indicates tha...
Definition: uspoof.h:397
@ USPOOF_AUX_INFO
Enable the return of auxillary (non-error) information in the upper bits of the check results value.
Definition: uspoof.h:516
@ USPOOF_WHOLE_SCRIPT_CONFUSABLE
When performing the two-string uspoof_areConfusable test, this flag in the return value indicates tha...
Definition: uspoof.h:407
@ USPOOF_SINGLE_SCRIPT_CONFUSABLE
When performing the two-string uspoof_areConfusable test, this flag in the return value indicates tha...
Definition: uspoof.h:387
@ USPOOF_ANY_CASE
This flag is deprecated and no longer affects the behavior of SpoofChecker.
Definition: uspoof.h:426
int32_t uspoof_getChecks(const USpoofChecker *sc, UErrorCode *status)
Get the set of checks that this Spoof Checker has been configured to perform.
void uspoof_setChecks(USpoofChecker *sc, int32_t checks, UErrorCode *status)
Specify the bitmask of checks that will be performed by uspoof_check.
const USet * uspoof_getInclusionSet(UErrorCode *status)
Get the set of Candidate Characters for Inclusion in Identifiers, as defined in http://unicode....
void uspoof_setRestrictionLevel(USpoofChecker *sc, URestrictionLevel restrictionLevel)
Set the loosest restriction level allowed for strings.
void uspoof_closeCheckResult(USpoofCheckResult *checkResult)
Close a USpoofCheckResult, freeing any memory that was being held by its implementation.
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.
URestrictionLevel uspoof_getRestrictionLevel(const USpoofChecker *sc)
Get the Restriction Level that will be tested if the checks include USPOOF_RESTRICTION_LEVEL.
URestrictionLevel
Constants from UAX #39 for use in uspoof_setRestrictionLevel, and for returned identifier restriction...
Definition: uspoof.h:530
@ 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:544
@ USPOOF_MODERATELY_RESTRICTIVE
The string classifies as Highly Restrictive, or all characters in the string are in the identifier pr...
Definition: uspoof.h:566
@ USPOOF_ASCII
All characters in the string are in the identifier profile and all characters in the string are in th...
Definition: uspoof.h:537
@ USPOOF_UNDEFINED_RESTRICTIVE
An undefined restriction level.
Definition: uspoof.h:590
@ USPOOF_RESTRICTION_LEVEL_MASK
Mask for selecting the Restriction Level bits from the return value of uspoof_check.
Definition: uspoof.h:584
@ USPOOF_MINIMALLY_RESTRICTIVE
All characters in the string are in the identifier profile.
Definition: uspoof.h:572
@ USPOOF_HIGHLY_RESTRICTIVE
The string classifies as Single Script, or all characters in the string are in the identifier profile...
Definition: uspoof.h:558
@ USPOOF_UNRESTRICTIVE
Any valid identifiers, including characters outside of the Identifier Profile.
Definition: uspoof.h:578
void uspoof_setAllowedUnicodeSet(USpoofChecker *sc, const icu::UnicodeSet *chars, UErrorCode *status)
Limit the acceptable characters to those specified by a Unicode Set.
USpoofChecker * uspoof_clone(const USpoofChecker *sc, UErrorCode *status)
Clone a Spoof Checker.
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.
int32_t uspoof_areConfusableUnicodeString(const USpoofChecker *sc, const icu::UnicodeString &s1, const icu::UnicodeString &s2, UErrorCode *status)
A version of uspoof_areConfusable accepting UnicodeStrings.
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.
int32_t uspoof_check2UnicodeString(const USpoofChecker *sc, const icu::UnicodeString &id, USpoofCheckResult *checkResult, UErrorCode *status)
Check the specified string for possible security issues.
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.
int32_t uspoof_getCheckResultChecks(const USpoofCheckResult *checkResult, UErrorCode *status)
Indicates which of the spoof check(s) have failed.
const icu::UnicodeSet * uspoof_getRecommendedUnicodeSet(UErrorCode *status)
Get the set of characters from Recommended Scripts for Inclusion in Identifiers, as defined in http:/...
const USet * uspoof_getRecommendedSet(UErrorCode *status)
Get the set of characters from Recommended Scripts for Inclusion in Identifiers, as defined in http:/...
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...
const USet * uspoof_getAllowedChars(const USpoofChecker *sc, UErrorCode *status)
Get a USet for the characters permitted in an identifier.
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.
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.
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.
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...
struct USpoofCheckResult USpoofCheckResult
Definition: uspoof.h:369
void uspoof_close(USpoofChecker *sc)
Close a Spoof Checker, freeing any memory that was being held by its implementation.
int32_t uspoof_checkUnicodeString(const USpoofChecker *sc, const icu::UnicodeString &id, int32_t *position, UErrorCode *status)
Check the specified string for possible security issues.
void uspoof_setAllowedChars(USpoofChecker *sc, const USet *chars, UErrorCode *status)
Limit the acceptable characters to those specified by a Unicode Set.
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.
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.
int32_t uspoof_areConfusable(const USpoofChecker *sc, const UChar *id1, int32_t length1, const UChar *id2, int32_t length2, UErrorCode *status)
Check the whether two specified strings are visually confusable.
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...
USpoofChecker * uspoof_open(UErrorCode *status)
Create a Unicode Spoof Checker, configured to perform all checks except for USPOOF_LOCALE_LIMIT and U...
const icu::UnicodeSet * uspoof_getInclusionUnicodeSet(UErrorCode *status)
Get the set of Candidate Characters for Inclusion in Identifiers, as defined in http://unicode....
struct USpoofChecker USpoofChecker
typedef for C of USpoofChecker
Definition: uspoof.h:362
const icu::UnicodeSet * uspoof_getAllowedUnicodeSet(const USpoofChecker *sc, UErrorCode *status)
Get a UnicodeSet for the characters permitted in an identifier.
const char * uspoof_getAllowedLocales(USpoofChecker *sc, UErrorCode *status)
Get a list of locales for the scripts that are acceptable in strings to be checked.
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.
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