How can Unicode normalization and grapheme clusters break validation, search or length limits?
Answer
Visually identical text can use different code-point sequences, and one user-perceived character can contain several code points. Byte, code-unit, code-point and grapheme counts therefore answer different questions. Test composed and decomposed forms, combining marks, emoji sequences and mixed scripts; define where normalization occurs, preserve security-relevant distinctions, and apply user-facing length rules to grapheme clusters when appropriate.
Strong answer includes
- distinguishes bytes, code points and grapheme clusters
- tests canonically equivalent representations
- defines normalization and security boundaries explicitly
Practical example
A username field rejects 'cafe' typed with a precomposed accented e but silently accepts the same-looking name typed with a combining acute accent as a separate code point, letting a user register two visually identical usernames that a naive byte-equality check treats as different strings, a bug caught only by testing NFC versus NFD forms of the same word.