Skip to content

Add server.allowed-characters (IRC formatting bytes and printable Unicode glyphs in identifiers) - #2457

Closed
kevinpostal wants to merge 2 commits into
ergochat:masterfrom
kevinpostal:pr/allowed-characters
Closed

kevinpostal wants to merge 2 commits into
ergochat:masterfrom
kevinpostal:pr/allowed-characters

Conversation

@kevinpostal

Copy link
Copy Markdown

Configurable control over which characters are legal in identifiers (nicknames, account names, channel names), extracted from waveplate/ergo branch ts6-linking (commits ac7e06d, 8c3ad28, author @waveplate, cherry-picked verbatim).

Two new flags under server.allowed-characters (both default false; documented in default.yaml and traditional.yaml):

    # allowed-characters:
        # allow IRC formatting/control characters (bold, color, italics, underline, etc.)
        # irc-formatting: false
        # allow printable Unicode glyphs (emoji, symbols, combining marks, legacy computing, block elements)
        # printable-glyphs: false

What the change does (verified against the diff):

  • irc/strings.go: new AllowedCharactersConfig{IRCFormatting, PrintableGlyphs} type and a package-global set at startup from config (irc/server.go); containsDisallowedControlChars permits exactly these control bytes when irc-formatting is on (verified in the diff):
    case 0x02, 0x03, 0x04, 0x0F, 0x11, 0x16, 0x1D, 0x1E, 0x1F:
    i.e. bold, colour, hex-colour, reset, monospace, reverse, italic, strikethrough, underline. All other C0 controls and DEL remain forbidden.
  • Casefolding strips formatting first (ircfmt.Strip in both Casefold and Skeleton), so \\x02foo and foo casefold identically and collide instead of coexisting as confusingly similar nicks.
  • When printable-glyphs is on and the configured casemapping's PRECIS casefold rejects a glyph, Casefold falls back to the permissive mapping (i18n.CasemappingPermissive) rather than rejecting the identifier.
  • irc/config.go: rejects builds where i18n was compiled out but the config asks for a non-ASCII casemapping or printable-glyphs. (The second commit, 8c3ad28, is a gofmt fix to that hunk plus removal of a test case covering a Unicode 16.0 character unsupported by the bundled PRECIS tables.)
  • Tests: TestAllowedCharactersIRCFormatting and TestAllowedCharactersPrintableGlyphs in irc/strings_test.go — both pass with full build tags (make test uses -tags "i18n mysql postgresql sqlite"; without the i18n tag the glyphs test skips, as designed).

Motivation: the server-linking work needs charset parity with linked peers whose users may carry formatting bytes or non-ASCII glyphs in their nicks; without this the link would force-rename or reject those users.

Testing: make test (gencapdefs check, gofmt check, vet, unit tests, full and empty tag sets) passes locally on this branch, exit 0, no failures. make irctest was NOT run (needs the irctest harness).

Author credit: @waveplate.

Copilot AI lite review requested due to automatic review settings September 20, 2026 05:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Two moderate issues remain in operator validation ordering and 0x04 formatting-byte handling.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds configurable support for IRC formatting bytes and printable Unicode glyphs in identifiers.

Changes:

  • Adds and documents server.allowed-characters.
  • Updates identifier validation, casefolding, skeleton generation, and startup wiring.
  • Adds tests and build validation for formatting and Unicode support.
File Summary
traditional.yaml Documents the new settings.
irc/​strings.go Implements character filtering and casefolding. Moderate (3 votes): 0x04 is allowlisted but not stripped, so hex-colour identifiers remain rejected.
irc/​strings_test.go Tests formatting and printable glyph support.
irc/​server.go Applies the runtime configuration.
irc/​i18n/​strings.go Supports permissive Unicode handling.
irc/​config.go Parses and validates configuration. Moderate (1 vote): operator validation occurs before the configured character policy is applied.
irc/​client_lookup_set.go Adjusts nickname safety checks.
default.yaml Documents the new settings.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread irc/strings.go
if b < 32 || b == 127 {
if allowIRCFormatting {
switch b {
case 0x02, 0x03, 0x04, 0x0F, 0x11, 0x16, 0x1D, 0x1E, 0x1F:
@slingamn

Copy link
Copy Markdown
Member

See #2015 and #1718 for context.

@slingamn slingamn closed this Sep 22, 2026
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.

3 participants