Skip to content

Preferences: an accent colour with a + after the # is taken, so #+fffff sets the accent to #0fffff #22089

Done

Description

@CamWight

Reproduced on: main fbf7ed5 (built from source), Windows 11. The check was a test on solidcraft-theme, run once on that tree and not committed.

parse_accent (crates/theme/src/lib.rs:418) reads the Accent preference from #10968. It should take #rrggbb or "" and nothing else, but it also takes text with a + where the first digit belongs. It checks the length (six characters after the #). Then it gives the text to egui's Color32::from_hex, which reads all six characters with one u32::from_str_radix, and from_str_radix takes a leading +.

Steps

  1. Send ui.prefs {"accent": "#+fffff"} over the control channel, or put "accent": "#+fffff" in the preferences file.
  2. Use a theme that accepts an accent (Light or Dark).

The Accent row's colour field and its swatches can't make this text. The field writes #rrggbb itself, and since #16716 its hex box uses the strict rule in solidcraft_color::hex. So the colour field and swatches can't make it; only the control channel, an agent or a hand-edited preferences file can.

Expected

ui.prefs refuses it with its own message, "accent must be a colour as #rrggbb, or "" for the theme's own" (crates/ui-egui/src/prefs.rs:3078), and the preferences file falls back to the theme's accent.

Actual

parse_accent takes it, so ui.prefs's check at prefs.rs:3078 lets it through and the accent paints as that colour. I ran parse_accent itself, below; I didn't drive ui.prefs in the app.

parse_accent("#00ff00")     -> Some([0, 255, 0, 255])
parse_accent("#+fffff")     -> Some([15, 255, 255, 255])   (#0fffff)
parse_accent("#+0000f")     -> Some([0, 0, 15, 255])       (#00000f)
parse_accent("#-ffff0")     -> None
parse_accent("##00ff0")     -> None
parse_accent("#0x00ff")     -> None
parse_accent("  #ABCDEF  ") -> Some([171, 205, 239, 255])

The fix I'd suggest

parse_accent reads through solidcraft_color::hex::parse after its trim, and refuses an alpha. That's the rule #16716 put in one place for theme files, the colour field, 3MF and the appearance dialog. solidcraft-theme already depends on solidcraft-color, so it's a few lines and no new dependency. A test beside the theme crate's tests would cover #+fffff and #+0000f, and keep ##00ff0 and #00ff00ff refused as they are today.

Hi @dudedagger42, thanks for the accent row in #10968. I found this while moving our command colour readers onto that same shared rule (#18745 / #18746). I've kept it out of that PR because the accent is your code, so it's all yours if you'd like it. If you'd rather I took it, just say and I'll open a small PR.

Activity

  1. added
    needs-triage
    on Nov 25, 2026
  2. EldarPolitkin commented on Nov 25, 2026

    @EldarPolitkin
    Contributor

    Confirmed on main fc6907a7d3 with a test on solidcraft-theme (cargo test -p solidcraft-theme --lib), asserting that parse_accent refuses a sign after the #:

    taken as an accent: [("#+fffff", #0F_FF_FF_FF), ("#+FFFFF", #0F_FF_FF_FF), ("#+0000f", #00_00_0F_FF)]
    test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 15 filtered out
    

    Only a + followed by five hex digits gets through. #+ffff, #-fffff, # fffff, #ffffé and non-ASCII digits are already refused, and #3B82F6 is still taken. The fix belongs in parse_accent itself (crates/theme/src/lib.rs), so ui.prefs, the preferences file and the Interface page all get it. I'll take this one.

  3. EldarPolitkin commented on Nov 25, 2026

    @EldarPolitkin
    Contributor

    /claim

  4. added
    in progress
    on Nov 25, 2026
  5. github-actions commented on Nov 25, 2026

    @github-actions
    Contributor

    Claimed by @EldarPolitkin. Please open a draft PR referencing #22089 within 72 h; the claim lapses otherwise. /unclaim releases it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in progressneeds-triage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions