[PR #7705] UUID: require ASCII hex digits and reject multi-byte slices #7775

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

📋 Pull Request Information

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

Base: main ← Head: fix/7660-uuid-from-text-multibyte-panic


📝 Commits (1)

  • 3f70e22 UUID: require ASCII hex digits and reject multi-byte slices

📊 Changes

1 file changed (+37 additions, -2 deletions)

View changed files

📝 crates/horizon-client-core/src/uuid.rs (+37 -2)

📄 Description

Opened by fy2ne's AI agent (Antigravity), not by fy2ne personally.

What and why

Fixes #7660

uuid_from_text collected non-dash characters into a String and checked hex.len() == 32 before slicing at fixed byte offsets [i * 8..i * 8 + 8]. Because len() and string slicing operate on byte boundaries rather than character boundaries:

  1. Multi-byte UTF-8 strings whose byte length equals 32 (such as "€€€€€€€€€€aa", reachable from /scoreboard holder names or NBT strings) sliced inside a UTF-8 character and panicked.
  2. u32::from_str_radix accepts leading + signs, allowing strings like +0000001-0000-0000-0000-000000000000 to be wrongly parsed as valid UUIDs.

This updates uuid_from_text to validate non-dash bytes with is_ascii_hexdigit(), returning None immediately on any non-hex or multi-byte characters and avoiding mid-character slicing entirely.

Kind

  • parity: Horizon now does what vanilla 26.3 does
  • bug: a crash or a breakage
  • perf: faster, or less memory
  • feature: something new for players (listed under New in the release notes)
  • extra: Horizon-only, off by default
  • tooling: tools, CI, tests, harnesses
  • docs

Vanilla reference

java.util.UUID.fromString (requires valid hex digit groups, rejects multi-byte sequences and signed integers).

Other projects' code

none

Self-check

Check Result
Scope ✅ 1 file, +37 −2
Cargo.lock ✅ unchanged
Public tree ✅
rustfmt ✅
tests: horizon-client-core ✅ 58 passed

🔄 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/7705 **Author:** [@fy2ne](https://github.com/fy2ne) **Created:** 11/2/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/7660-uuid-from-text-multibyte-panic` --- ### 📝 Commits (1) - [`3f70e22`](https://github.com/horizon-rust/horizon/commit/3f70e22ce5d50f3ef936aa61109270ba98f0168b) UUID: require ASCII hex digits and reject multi-byte slices ### 📊 Changes **1 file changed** (+37 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-core/src/uuid.rs` (+37 -2) </details> ### 📄 Description > Opened by fy2ne's AI agent (Antigravity), not by fy2ne personally. ## What and why Fixes #7660 `uuid_from_text` collected non-dash characters into a `String` and checked `hex.len() == 32` before slicing at fixed byte offsets `[i * 8..i * 8 + 8]`. Because `len()` and string slicing operate on byte boundaries rather than character boundaries: 1. Multi-byte UTF-8 strings whose byte length equals 32 (such as `"€€€€€€€€€€aa"`, reachable from `/scoreboard` holder names or NBT strings) sliced inside a UTF-8 character and panicked. 2. `u32::from_str_radix` accepts leading `+` signs, allowing strings like `+0000001-0000-0000-0000-000000000000` to be wrongly parsed as valid UUIDs. This updates `uuid_from_text` to validate non-dash bytes with `is_ascii_hexdigit()`, returning `None` immediately on any non-hex or multi-byte characters and avoiding mid-character slicing entirely. ## Kind - [ ] parity: Horizon now does what vanilla 26.3 does - [x] bug: a crash or a breakage - [ ] perf: faster, or less memory - [ ] feature: something new for players (listed under New in the release notes) - [ ] extra: Horizon-only, off by default - [ ] tooling: tools, CI, tests, harnesses - [ ] docs ## Vanilla reference `java.util.UUID.fromString` (requires valid hex digit groups, rejects multi-byte sequences and signed integers). ## Other projects' code none ## Self-check | Check | Result | | --- | --- | | Scope | ✅ 1 file, +37 −2 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | rustfmt | ✅ | | tests: horizon-client-core | ✅ 58 passed | --- <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#7775
No description provided.