Skip to content

feat(ui): parse and validate custom-theme colour values into SGR#475

Merged
indaco merged 1 commit into
mainfrom
feat/custom-theme-value-parser
Jun 11, 2026
Merged

feat(ui): parse and validate custom-theme colour values into SGR#475
indaco merged 1 commit into
mainfrom
feat/custom-theme-value-parser

Conversation

@indaco

@indaco indaco commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Description

Adds the pure core for user-defined colour themes: the runtime palette/registry types and a colour-value parser that accepts only #rgb / #rrggbb hex, [r, g, b] integer arrays, and a single 0–255 256-colour index - and constructs the SGR escape string itself from validated integers. No file is read yet and nothing consults these types; this lands the security-critical, injection-proof conversion as one fully-tested leaf ahead of the loader.

Any malformed or escape-bearing value is rejected, never emitted: out-of-range ints, wrong-length or non-hex strings, wrong-arity / non-integer arrays, and - critically - anything carrying ESC, ;, or m cannot be smuggled, because the output is built from parsed u8s only. CSS-style rgba(), hsl(), named colours and 8-digit RGBA hex are explicitly rejected.

The leaf imports only std (plus themes for the shared Role/Polarity/NamedPalette), preserving the CLI/TUI → color/themes dependency direction.

Related Issue

  • None

Notes for Reviewers

  • None

This is part 2 of 2 in a stack made with GitButler:

User themes hinge on safe colour parsing: each role's colour is validated to
integers and the SGR escape is rebuilt by malt, so an untrusted theme file can
never inject terminal escapes. Accepts #rgb/#rrggbb hex, [r,g,b] arrays and
256-colour indexes; every other or escape-bearing value is rejected.
@indaco indaco changed the title ## Description feat(ui): parse and validate custom-theme colour values into SGR Jun 10, 2026
@indaco indaco merged commit d5177a7 into main Jun 11, 2026
3 checks passed
@indaco indaco deleted the feat/custom-theme-value-parser branch June 11, 2026 06:15
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.

1 participant