Spoofchecker
class Spoofchecker (View source)
This class is provided because Unicode contains large number of characters and incorporates the varied writing systems of the world and their incorrect usage can expose programs or systems to possible security attacks using characters similarity.
Provided methods allow to check whether an individual string is likely an attempt at confusing the reader (spoof detection), such as "pаypаl" spelled with Cyrillic 'а' characters.
Constants
| SINGLE_SCRIPT_CONFUSABLE |
|
| MIXED_SCRIPT_CONFUSABLE |
|
| WHOLE_SCRIPT_CONFUSABLE |
|
| ANY_CASE |
|
| SINGLE_SCRIPT |
|
| INVISIBLE |
|
| CHAR_LIMIT |
|
| ASCII |
|
| HIGHLY_RESTRICTIVE |
|
| MODERATELY_RESTRICTIVE |
|
| MINIMALLY_RESTRICTIVE |
|
| UNRESTRICTIVE |
|
| SINGLE_SCRIPT_RESTRICTIVE |
|
| MIXED_NUMBERS |
|
| HIDDEN_OVERLAY |
|
|
IGNORE_SPACE
Since: 8.4
|
|
|
CASE_INSENSITIVE
Since: 8.4
|
|
|
ADD_CASE_MAPPINGS
Since: 8.4
|
|
|
SIMPLE_CASE_INSENSITIVE
Since: 8.4
|
|
Methods
(PHP >= 5.4.0, PECL intl >= 2.0.0)
Constructor
(PHP >= 5.4.0, PECL intl >= 2.0.0)
Checks if a given text contains any suspicious characters
(PHP >= 5.4.0, PECL intl >= 2.0.0)
Checks if a given text contains any confusable characters
(PHP >= 5.4.0, PECL intl >= 2.0.0)
Locales to use when running checks
(PHP >= 5.4.0, PECL intl >= 2.0.0)
Set the checks to run
Set the restriction level
Set the set of characters allowed when running checks
Details
__construct()
(PHP >= 5.4.0, PECL intl >= 2.0.0)
Constructor
bool
isSuspicious(string $string, string $errorCode = null)
(PHP >= 5.4.0, PECL intl >= 2.0.0)
Checks if a given text contains any suspicious characters
bool
areConfusable(string $string1, string $string2, int $errorCode = null)
(PHP >= 5.4.0, PECL intl >= 2.0.0)
Checks if a given text contains any confusable characters
void
setAllowedLocales(string $locales)
(PHP >= 5.4.0, PECL intl >= 2.0.0)
Locales to use when running checks
void
setChecks(int $checks)
(PHP >= 5.4.0, PECL intl >= 2.0.0)
Set the checks to run
void
setRestrictionLevel(int $level)
Set the restriction level
Sets the restriction level of SpoofChecker::isSuspicious.
void
setAllowedChars(string $pattern, int $patternOptions = 0)
Set the set of characters allowed when running checks
Restricts the characters that are considered acceptable by subsequent checks to the set described by pattern. Any character outside of this set causes Spoofchecker::isSuspicious to report a result.