Skip to content

Commit 4d29948

Browse files
committed
Tweaks and minor fixes
1 parent 8fab448 commit 4d29948

File tree

1 file changed

+38
-26
lines changed

1 file changed

+38
-26
lines changed

reference/constraints/NoSuspiciousCharacters.rst

Lines changed: 38 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,27 @@ NoSuspiciousCharacters
55

66
The ``NoSuspiciousCharacters`` constraint was introduced in Symfony 6.3.
77

8-
..
8+
Validates that the given string does not contain characters used in spoofing
9+
security attacks, such as invisible characters such as zero-width spaces or
10+
characters that are visually similar.
911

10-
Because Unicode contains such a large number of characters and incorporates
11-
the varied writing systems of the world, incorrect usage can expose programs
12-
or systems to possible security attacks.
12+
"symfony.com" and "ѕymfony.com" look similar, but their first letter is different
13+
(in the second string, the "s" is actually a `cyrillic small letter dze`_).
14+
This can make a user think they'll navigate to Symfony's website, whereas it
15+
would be somewhere else.
1316

14-
`Unicode® Technical Standard #39`_
17+
This is a kind of `spoofing attack`_ (called "IDN homograph attack"). It tries
18+
to identify something as something else to exploit the resulting confusion.
19+
This is why it is recommended to check user-submitted, public-facing identifiers
20+
for suspicious characters in order to prevent such attacks.
1521

16-
"symfony.com" and "ѕymfony.com" look similar, but the latter actually starts with a
17-
`cyrillic small letter dze`_. It could make a user think they'll navigate to Symfony's
18-
website, whereas it would be somewhere else.
19-
This is a kind of `spoofing attack`_ (called "IDN homograph attack"). It tries to
20-
identify something as something else to exploit the resulting confusion.
21-
This is why it is recommended to check user-submitted, public-facing identifiers for
22-
suspicious characters in order to prevent such attacks.
22+
Because Unicode contains such a large number of characters and incorporates the
23+
varied writing systems of the world, incorrect usage can expose programs or
24+
systems to possible security attacks.
2325

24-
This constraint ensures strings or :phpclass:`Stringable`s do not include any
25-
suspicious characters. As it leverages PHP's :phpclass:`Spoofchecker`, the intl
26-
extension must be enabled to use it.
26+
That's why this constraint ensures strings or :phpclass:`Stringable`s do not
27+
include any suspicious characters. As it leverages PHP's :phpclass:`Spoofchecker`,
28+
the intl extension must be enabled to use it.
2729

2830
========== ===================================================================
2931
Applies to :ref:`property or method <validation-property-target>`
@@ -34,8 +36,8 @@ Validator :class:`Symfony\\Component\\Validator\\Constraints\\NoSuspiciousChar
3436
Basic Usage
3537
-----------
3638

37-
The following constraint will ensures a username cannot be spoofed by using many
38-
detection mechanisms:
39+
The following constraint will use different detection mechanisms to ensure that
40+
the username is not spoofed:
3941

4042
.. configuration-block::
4143

@@ -103,9 +105,13 @@ Options
103105

104106
This option is a bitmask of the checks you want to perform on the string:
105107

106-
* ``NoSuspiciousCharacters::CHECK_INVISIBLE`` checks for the presence of invisible characters such as zero-width spaces, or character sequences that are likely not to display, such as multiple occurrences of the same non-spacing mark.
107-
* ``NoSuspiciousCharacters::CHECK_MIXED_NUMBERS`` (usable with ICU 58 or higher) checks for numbers from different numbering systems.
108-
* ``NoSuspiciousCharacters::CHECK_HIDDEN_OVERLAY`` (usable with ICU 62 or higher) checks for combining characters hidden in their preceding one.
108+
* ``NoSuspiciousCharacters::CHECK_INVISIBLE`` checks for the presence of invisible
109+
characters such as zero-width spaces, or character sequences that are likely
110+
not to display, such as multiple occurrences of the same non-spacing mark.
111+
* ``NoSuspiciousCharacters::CHECK_MIXED_NUMBERS`` (usable with ICU 58 or higher)
112+
checks for numbers from different numbering systems.
113+
* ``NoSuspiciousCharacters::CHECK_HIDDEN_OVERLAY`` (usable with ICU 62 or higher)
114+
checks for combining characters hidden in their preceding one.
109115

110116
You can also configure additional requirements using :ref:`locales <locales>` and
111117
:ref:`restrictionLevel <restrictionlevel>`.
@@ -131,15 +137,22 @@ Passing an empty array, or configuring :ref:`restrictionLevel <restrictionlevel>
131137
Configures the set of acceptable characters for the validated string through a
132138
specified "level":
133139

134-
* ``NoSuspiciousCharacters::RESTRICTION_LEVEL_MINIMAL`` requires the string's characters to match :ref:`the configured locales <locales>`'.
135-
* ``NoSuspiciousCharacters::RESTRICTION_LEVEL_MODERATE`` also requires the string to be `covered`_ by Latin and any one other `Recommended`_ or `Limited Use`_ script, except Cyrillic, Greek, and Cherokee.
136-
* ``NoSuspiciousCharacters::RESTRICTION_LEVEL_HIGH`` (usable with ICU 58 or higher) also requires the string to be `covered`_ by any of the following sets of scripts:
140+
* ``NoSuspiciousCharacters::RESTRICTION_LEVEL_MINIMAL`` requires the string's
141+
characters to match :ref:`the configured locales <locales>`'.
142+
* ``NoSuspiciousCharacters::RESTRICTION_LEVEL_MODERATE`` also requires the string
143+
to be `covered`_ by Latin and any one other `Recommended`_ or `Limited Use`_
144+
script, except Cyrillic, Greek, and Cherokee.
145+
* ``NoSuspiciousCharacters::RESTRICTION_LEVEL_HIGH`` (usable with ICU 58 or higher)
146+
also requires the string to be `covered`_ by any of the following sets of scripts:
137147

138148
* Latin + Han + Bopomofo (or equivalently: Latn + Hanb)
139149
* Latin + Han + Hiragana + Katakana (or equivalently: Latn + Jpan)
140150
* Latin + Han + Hangul (or equivalently: Latn + Kore)
141-
* ``NoSuspiciousCharacters::RESTRICTION_LEVEL_SINGLE_SCRIPT`` also requires the string to be `single-script`_.
142-
* ``NoSuspiciousCharacters::RESTRICTION_LEVEL_ASCII`` (usable with ICU 58 or higher) also requires the string's characters to be in the ASCII range.
151+
152+
* ``NoSuspiciousCharacters::RESTRICTION_LEVEL_SINGLE_SCRIPT`` also requires the
153+
string to be `single-script`_.
154+
* ``NoSuspiciousCharacters::RESTRICTION_LEVEL_ASCII`` (usable with ICU 58 or higher)
155+
also requires the string's characters to be in the ASCII range.
143156

144157
You can accept all characters by setting this option to
145158
``NoSuspiciousCharacters::RESTRICTION_LEVEL_NONE``.
@@ -148,7 +161,6 @@ You can accept all characters by setting this option to
148161

149162
.. include:: /reference/constraints/_payload-option.rst.inc
150163

151-
.. _`Unicode® Technical Standard #39`: https://unicode.org/reports/tr39/
152164
.. _`cyrillic small letter dze`: https://graphemica.com/%D1%95
153165
.. _`spoofing attack`: https://en.wikipedia.org/wiki/Spoofing_attack
154166
.. _`single-script`: https://unicode.org/reports/tr39/#def-single-script

0 commit comments

Comments
 (0)