Skip to content

Add NoSuspiciousCharacters constraint (spoofing checks)#95

Merged
strider2038 merged 6 commits into
mainfrom
cursor/-bc-48562006-fb29-44ad-b7bd-543338a95fd9-3070
Apr 6, 2026
Merged

Add NoSuspiciousCharacters constraint (spoofing checks)#95
strider2038 merged 6 commits into
mainfrom
cursor/-bc-48562006-fb29-44ad-b7bd-543338a95fd9-3070

Conversation

@strider2038
Copy link
Copy Markdown
Contributor

@strider2038 strider2038 commented Apr 5, 2026

Summary

Adds a NoSuspiciousCharacters constraint inspired by Symfony’s NoSuspiciousCharacters (ICU Spoofchecker), implemented without CGO using unicode / unicode/utf8 and golang.org/x/text/language for locale script hints.

API

  • it.HasNoSuspiciousCharacters() (declarative Has* naming) with options: WithChecks, WithSuspiciousRestriction, WithSuspiciousLocales, per-violation message/error overrides, When / WhenGroups. Constraint type: HasNoSuspiciousCharactersConstraint.
  • validate.NoSuspiciousCharacters with validate.WithSuspiciousChecks, WithSuspiciousRestriction, WithSuspiciousLocales.
  • is.NoSuspiciousCharacters boolean helper.
  • New errors: ErrSuspiciousInvisible, ErrSuspiciousMixedNumbers, ErrSuspiciousHiddenOverlay, ErrSuspiciousCharactersRestriction with English defaults and Russian translations (Symfony-aligned wording where applicable).

Behavior notes

  • Detects Cf / Zl / Zp / NUL as “invisible” style issues; mixed decimal digit scripts (Common-script digits vs script-specific Nd); Latin i/j/l + U+0307 as hidden overlay.
  • Locale restriction maps BCP 47 tags via language.Tag.Script() to unicode.Scripts (with a small ISO15924→script-name map for composite scripts like Jpan/Kore); Latin is always allowed alongside locale scripts for realistic identifiers.
  • Single-script mode flags mixed non-Common letter/mark/number scripts.

Semantics may differ from ICU on edge cases; this is documented in godoc.

Merge

Branch merged latest origin/main (includes IBAN); changelog conflict resolved by listing both IBAN and NoSuspiciousCharacters under [Unreleased]Added.

Changelog

  • [Unreleased]Changed: it constructor renamed from NoSuspiciousCharacters to HasNoSuspiciousCharacters for declarative naming.

Testing

  • go test -race ./...
  • golangci-lint run (v2.11.4)

Closes Linear IGO-43 when merged (optional follow-up: align further with Symfony restriction levels).

Open in Web Open in Cursor 

cursoragent and others added 6 commits April 5, 2026 06:41
Implement it.NoSuspiciousCharacters with Symfony-aligned check flags,
optional locale and single-script restrictions, validate/is helpers,
messages and translations, tests and examples. Behavior approximates
Symfony ICU Spoofchecker without CGO; document differences in godoc.

Co-authored-by: Igor Lazarev <strider2038@yandex.ru>
Resolve CHANGELOG [Unreleased] by keeping both IBAN (main) and
NoSuspiciousCharacters entries.

Co-authored-by: Igor Lazarev <strider2038@yandex.ru>
Use declarative Has* naming for package it; document convention in
validation-add-constraint skill. Add CHANGELOG [Changed] note.

Co-authored-by: Igor Lazarev <strider2038@yandex.ru>
Feature is unreleased on this branch; public API is HasNoSuspiciousCharacters
from the start—no rename to document under [Unreleased].

Co-authored-by: Igor Lazarev <strider2038@yandex.ru>
…d tests

Remove is.NoSuspiciousCharacters. Replace it.WithChecks with bitmask
methods CheckInvisible/MixedNumbers/HiddenOverlay and Without* defaults.
Extend validate tests for masks, locales edge cases, helpers, and Zl/Zp/Cf.
Update changelog and validation-add-constraint skill.

Co-authored-by: Igor Lazarev <strider2038@yandex.ru>
- needsScriptCheck: include Unicode Nd for locale restriction
- iso15924ToUnicodeScripts: Hira/Kana/Hang/Bopo aliases
- Tests: ja-Hira + hiragana, en + Arabic-Indic digits, Hira/Kana tables
- CHANGELOG [Unreleased] Fixed

Co-authored-by: Igor Lazarev <strider2038@yandex.ru>
@strider2038 strider2038 marked this pull request as ready for review April 6, 2026 17:02
@strider2038 strider2038 merged commit d1f1738 into main Apr 6, 2026
2 checks passed
@strider2038 strider2038 deleted the cursor/-bc-48562006-fb29-44ad-b7bd-543338a95fd9-3070 branch April 6, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants