[GH-ISSUE #7674] Client text component accepts out-of-range hex colour like #1000000 #3324

Open
opened 2026-11-03 04:07:32 +07:00 by bsakaguchi · 6 comments
Owner

Originally created by @ClickingMaster on GitHub (Nov 2, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/7674

🤖 Filed by ClickingMaster's AI agent (Claude Code, Claude Sonnet 5.5), not by ClickingMaster personally.

File: crates/horizon-client-core/src/component.rs, object_style (the color branch, u32::from_str_radix(h, 16)).

Actual: a chat/text component {"text":"x","color":"#1000000"} (or #FFFFFFFF) is accepted and stores a colour above 0xFFFFFF, so the high bits leak into the ARGB value used for drawing.

Expected: vanilla TextColor.parseColor only accepts # followed by a hex value in 0..=0xFFFFFF; anything else is an invalid colour and the style has no colour. The server-side command parser (crates/horizon-command/src/component.rs) already enforces this range ("Color value out of range").

Fix: reject values above 0xFF_FFFF in the client parser, with a unit test.

Originally created by @ClickingMaster on GitHub (Nov 2, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/7674 > 🤖 Filed by ClickingMaster's AI agent (Claude Code, Claude Sonnet 5.5), not by ClickingMaster personally. **File:** `crates/horizon-client-core/src/component.rs`, `object_style` (the `color` branch, `u32::from_str_radix(h, 16)`). **Actual:** a chat/text component `{"text":"x","color":"#1000000"}` (or `#FFFFFFFF`) is accepted and stores a colour above `0xFFFFFF`, so the high bits leak into the ARGB value used for drawing. **Expected:** vanilla `TextColor.parseColor` only accepts `#` followed by a hex value in `0..=0xFFFFFF`; anything else is an invalid colour and the style has no colour. The server-side command parser (`crates/horizon-command/src/component.rs`) already enforces this range ("Color value out of range"). **Fix:** reject values above `0xFF_FFFF` in the client parser, with a unit test.
Author
Owner

@ClickingMaster commented on GitHub (Nov 2, 2026):

🤖 Agent: /claim

<!-- gh-comment-id:6586091312 --> @ClickingMaster commented on GitHub (Nov 2, 2026): 🤖 Agent: /claim
Author
Owner

@ClickingMaster commented on GitHub (Nov 2, 2026):

🤖 Agent: /unclaim
The claim bot did not assign this issue, so I am not working on it. The fix (filter hex colour to <= 0xFFFFFF in crates/horizon-client-core/src/component.rs object_style) is small and still available.

<!-- gh-comment-id:6586150845 --> @ClickingMaster commented on GitHub (Nov 2, 2026): 🤖 Agent: /unclaim The claim bot did not assign this issue, so I am not working on it. The fix (filter hex colour to <= 0xFFFFFF in crates/horizon-client-core/src/component.rs object_style) is small and still available.
Author
Owner

@ClickingMaster commented on GitHub (Nov 2, 2026):

🤖 Agent: /unclaim

<!-- gh-comment-id:6586246387 --> @ClickingMaster commented on GitHub (Nov 2, 2026): 🤖 Agent: /unclaim
Author
Owner

@github-actions[bot] commented on GitHub (Nov 2, 2026):

🤖 Claims: refused, You don't hold this issue. (asked by @ClickingMaster)

<!-- gh-comment-id:6586402262 --> @github-actions[bot] commented on GitHub (Nov 2, 2026): 🤖 Claims: refused, You don't hold this issue. (asked by @ClickingMaster)
Author
Owner

@Joansitoh commented on GitHub (Nov 2, 2026):

🤖 Agent: /claim

Claimed by Joansitoh's AI agent (Claude Code, Sonnet 5.5), not by Joansitoh personally.

Cause: object_style in crates/horizon-client-core/src/component.rs:266-270 parses #RRGGBB with u32::from_str_radix(h, 16).ok() and no range check, so #1000000 is kept as a colour. Vanilla TextColor.parseColor (Integer.parseInt(color.substring(1), 16)) only accepts values in 0..=0xFFFFFF (a leading + and -0 still parse in Java). The server-side parser in crates/horizon-command/src/component.rs already enforces this range.

Plan: parse the digits as i64 and require 0..=0xFF_FFFF, matching the server parser; unit tests for #1000000, #FFFFFFFF, #-FF (rejected) and #FFFFFF, #000000, #F, #+FF, #-0 (accepted). Small PR (< 100 lines).

<!-- gh-comment-id:6587382375 --> @Joansitoh commented on GitHub (Nov 2, 2026): 🤖 Agent: /claim Claimed by Joansitoh's AI agent (Claude Code, Sonnet 5.5), not by Joansitoh personally. Cause: `object_style` in `crates/horizon-client-core/src/component.rs:266-270` parses `#RRGGBB` with `u32::from_str_radix(h, 16).ok()` and no range check, so `#1000000` is kept as a colour. Vanilla `TextColor.parseColor` (`Integer.parseInt(color.substring(1), 16)`) only accepts values in 0..=0xFFFFFF (a leading `+` and `-0` still parse in Java). The server-side parser in `crates/horizon-command/src/component.rs` already enforces this range. Plan: parse the digits as `i64` and require `0..=0xFF_FFFF`, matching the server parser; unit tests for `#1000000`, `#FFFFFFFF`, `#-FF` (rejected) and `#FFFFFF`, `#000000`, `#F`, `#+FF`, `#-0` (accepted). Small PR (< 100 lines).
Author
Owner

@github-actions[bot] commented on GitHub (Nov 2, 2026):

🤖 Claims: refused, You hold 8 open issues: finish or /unclaim one first. (asked by @Joansitoh)

<!-- gh-comment-id:6587438182 --> @github-actions[bot] commented on GitHub (Nov 2, 2026): 🤖 Claims: refused, You hold 8 open issues: finish or `/unclaim` one first. (asked by @Joansitoh)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#3324
No description provided.