hle(xgameui): treat maxTextLength=0 as default 1024-character limit #295

Open
github-bot wants to merge 1 commit from github-bot/gh-295 into main AGit
Owner

@⁠Caasares on GitHub · 2026-11-24 23:21 UTC · original
Caasares:fix/xgameui-max-text-length-zero → main · +121 −22 · 1 files · 1 commits · open

Fixes #248

Root Cause

Per GDK documentation for XGameUiShowTextEntryAsync, maxTextLength == 0 specifies the default limit of 1024 characters. Previously, crates/victory-hle/src/modules/xgameui.rs:

  • Passed max_length = 0 straight into ask / dialog::ask (EM_LIMITTEXT with wParam = 0 sets the edit control's maximum capacity rather than 1024).
  • Treated 0 as "no limit" inside limit(typed, max), returning all characters (e.g., all 1025 characters for a 1025-character input).

Fix

  • Added DEFAULT_MAX_TEXT_LENGTH = 1024 and effective_max_length(max) in crates/victory-hle/src/modules/xgameui.rs to normalize 0 to 1024.
  • Normalized max_length at entry in text_entry_async before calling ask and limit, updated limit to cap at effective_max_length(max) characters, and normalized dialog::ask / dialog::limit_text_wparam for EM_LIMITTEXT.
  • Added unit tests (max_length_zero_applies_1024_default and explicit_positive_limit_and_utf8_boundaries) covering maxTextLength = 0 on 1025-character ASCII and multi-byte UTF-8 inputs, explicit positive limits (16), shorter pass-through inputs, dialog::limit_text_wparam, and NUL-terminated buffer sizing.

Verification

  • cargo clippy --workspace --all-targets --locked -- -D warnings: passed (0 warnings)
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passed (0 warnings)
  • cargo test --workspace --locked: 498 passed, 0 failed, 7 ignored (including victory-hle 97 passed, 3 modules::xgameui::tests::*, and xtask::policy::tests::repository_passes_policy)
  • cargo fmt --all -- --check: fails only on pre-existing unformatted lines outside this diff (also present on pre-existing lines in xgameui.rs); all added/modified lines conform to rustfmt.toml.

AI-assisted contribution. Contains no game files, code, or assets.

**@⁠Caasares** on GitHub · 2026-11-24 23:21 UTC · [original](https://github.com/fxceless/victory-fork/pull/295) `Caasares:fix/xgameui-max-text-length-zero` → `main` · +121 −22 · 1 files · 1 commits · open Fixes #248 ## Root Cause Per GDK documentation for `XGameUiShowTextEntryAsync`, `maxTextLength == 0` specifies the default limit of `1024` characters. Previously, `crates/victory-hle/src/modules/xgameui.rs`: - Passed `max_length = 0` straight into `ask` / `dialog::ask` (`EM_LIMITTEXT` with `wParam = 0` sets the edit control's maximum capacity rather than `1024`). - Treated `0` as "no limit" inside `limit(typed, max)`, returning all characters (e.g., all 1025 characters for a 1025-character input). ## Fix - Added `DEFAULT_MAX_TEXT_LENGTH = 1024` and `effective_max_length(max)` in `crates/victory-hle/src/modules/xgameui.rs` to normalize `0` to `1024`. - Normalized `max_length` at entry in `text_entry_async` before calling `ask` and `limit`, updated `limit` to cap at `effective_max_length(max)` characters, and normalized `dialog::ask` / `dialog::limit_text_wparam` for `EM_LIMITTEXT`. - Added unit tests (`max_length_zero_applies_1024_default` and `explicit_positive_limit_and_utf8_boundaries`) covering `maxTextLength = 0` on 1025-character ASCII and multi-byte UTF-8 inputs, explicit positive limits (`16`), shorter pass-through inputs, `dialog::limit_text_wparam`, and NUL-terminated buffer sizing. ## Verification - `cargo clippy --workspace --all-targets --locked -- -D warnings`: passed (0 warnings) - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: passed (0 warnings) - `cargo test --workspace --locked`: 498 passed, 0 failed, 7 ignored (including `victory-hle` 97 passed, 3 `modules::xgameui::tests::*`, and `xtask::policy::tests::repository_passes_policy`) - `cargo fmt --all -- --check`: fails only on pre-existing unformatted lines outside this diff (also present on pre-existing lines in `xgameui.rs`); all added/modified lines conform to `rustfmt.toml`. *AI-assisted contribution. Contains no game files, code, or assets.*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:40:09 +00:00
Author
Owner

@⁠kaayzouee on GitHub · 2026-11-25 01:12 UTC · original

Duplicate of #291?

**@⁠kaayzouee** on GitHub · 2026-11-25 01:12 UTC · [original](https://github.com/fxceless/victory-fork/pull/295#issuecomment-7149319570) Duplicate of #291?
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/295/head:github-bot/gh-295'
git switch 'github-bot/gh-295'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-295'
git switch 'github-bot/gh-295'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-295'
git switch 'github-bot/gh-295'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-295'
git switch 'main'
git merge --squash 'github-bot/gh-295'
git switch 'main'
git merge --ff-only 'github-bot/gh-295'
git switch 'main'
git merge 'github-bot/gh-295'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.