[PR #7884] Reject out-of-range hex colours in text components #7879

Open
opened 2026-11-03 07:25:54 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7884
Author: @Joansitoh
Created: 11/2/2026
Status: 🔄 Open

Base: main ← Head: fix/7674-hex-colour-range


📝 Commits (1)

  • 061d571 Reject out-of-range hex colours in text components (TextColor.parseColor)

📊 Changes

2 files changed (+39 additions, -11 deletions)

View changed files

📝 crates/horizon-client-core/src/component.rs (+35 -4)
📝 crates/horizon-client-core/src/scoreboard.rs (+4 -7)

📄 Description

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

What

Text-component hex colours ("color": "#...") accepted any value that fit a u32 (#1000000, #FFFFFFFF). They now go through one shared hex_color helper, used by object_style (component.rs), style_from_json and the colour normalizer in canonical_component (scoreboard.rs). shadow_color was checked and is not affected.

Vanilla reference

net.minecraft.network.chat.TextColor.parseColor: # required, Integer.parseInt(rest, 16) (so a leading +/- and any digit count are accepted), result kept only if in 0..=0xFFFFFF.

How tested

New unit test with hand-written vanilla expectations: rejected #1000000, #FFFFFFFF, #-FF, #, #zz, FFFFFF, a huge value; accepted #FFFFFF, #000000, #F=15, #+FF=255, #-0=0; plus an end-to-end to_text check.

pr_ready (--quick --base upstream/main): scope 2 files +39 −11, public tree ✅, Python tests 614 ✅, rustfmt ✅, clippy ✅, horizon-client-core tests 57 ✅, doc tests ✅.
Harnesses run: chat_screen PASS, text_display PASS.
Remaining affected harnesses: run by CI's parity job.

Fixes #7674

Suggested label: none (fix)

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/7884 **Author:** [@Joansitoh](https://github.com/Joansitoh) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/7674-hex-colour-range` --- ### 📝 Commits (1) - [`061d571`](https://github.com/horizon-rust/horizon/commit/061d5710657e04b85e336b4851458e86868a5465) Reject out-of-range hex colours in text components (TextColor.parseColor) ### 📊 Changes **2 files changed** (+39 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-core/src/component.rs` (+35 -4) 📝 `crates/horizon-client-core/src/scoreboard.rs` (+4 -7) </details> ### 📄 Description > 🤖 Opened by Joansitoh's AI agent (Claude Code, Sonnet 5.5), not by Joansitoh personally. ## What Text-component hex colours (`"color": "#..."`) accepted any value that fit a `u32` (`#1000000`, `#FFFFFFFF`). They now go through one shared `hex_color` helper, used by `object_style` (component.rs), `style_from_json` and the colour normalizer in `canonical_component` (scoreboard.rs). `shadow_color` was checked and is not affected. ## Vanilla reference `net.minecraft.network.chat.TextColor.parseColor`: `#` required, `Integer.parseInt(rest, 16)` (so a leading `+`/`-` and any digit count are accepted), result kept only if in `0..=0xFFFFFF`. ## How tested New unit test with hand-written vanilla expectations: rejected `#1000000`, `#FFFFFFFF`, `#-FF`, `#`, `#zz`, `FFFFFF`, a huge value; accepted `#FFFFFF`, `#000000`, `#F`=15, `#+FF`=255, `#-0`=0; plus an end-to-end `to_text` check. **pr_ready** (`--quick --base upstream/main`): scope 2 files +39 −11, public tree ✅, Python tests 614 ✅, rustfmt ✅, clippy ✅, horizon-client-core tests 57 ✅, doc tests ✅. Harnesses run: `chat_screen` PASS, `text_display` PASS. Remaining affected harnesses: run by CI's parity job. Fixes #7674 Suggested label: none (fix) 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#7879
No description provided.