mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7897] [MERGED] fix(game): dungeon map tags and way-out words can't stall on long whitespace #7994
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#7994
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7897
Author: @SpicyMarinara
Created: 10/20/2026
Status: ✅ Merged
Merged: 10/20/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/dungeon-map-redos📝 Commits (2)
cb25a78fix(game): dungeon map tags and way-out words can't stall on long whitespacea534d34Merge branch 'staging' into fix/dungeon-map-redos📊 Changes
2 files changed (+120 additions, -3 deletions)
View changed files
📝
packages/shared/src/features/world/dungeon-map.ts(+13 -3)➕
scripts/regressions/game-dungeon-tags-redos.regression.ts(+107 -0)📄 Description
Linked issue
No issue: this clears CodeQL
js/polynomial-redosalerts 634 and 635 (high), which block the v2.5.1 promotion PR #7895.Why this change
CodeQL flagged two regular expressions in
packages/shared/src/features/world/dungeon-map.tsthat backtrack polynomially on library input, and those alerts block #7895. The slowdown is real:readGameDungeonTagsread the Game Master's[map: ...]tags with/\[map:\s*([^\]]*)\]/giu. A reply with[map:and 50,000 tabs but no]took about 4.5 s, and 10,000 open[map:took about 1 s. Removing only the\s*would still leave the second case quadratic.dungeonWayOutWordsremoved a trailing "down"/"up" with/\s+(down|up)$/u. An exit word like"x" + 50,000 spaces + "q"took about 4 s.What changed
readGameDungeonTagsfinds each[map:with a literal regex (samegiuflags) and its first]withindexOf, then trims the start of the body. It stops when no]follows, because the old regex could not match any later tag either. Each tag still runs to its first], and the search resumes after it, asmatchAlldid. The leave, reveal, name, kind and set rules are unchanged.dungeonWayOutWordsremoves the trailingdown/upwithendsWith+trimEnd, only when whitespace comes before it, as the regex did (\sandtrimEnduse the same characters).scripts/regressions/game-dungeon-tags-redos.regression.tspins outputs for normal input: leave, reveal, name, kind and set tags, mixed case, whitespace and lines inside tags, several tags, nested or unclosed tags, every set's way out in words and as an id, and exit words written by hand. The expected values come from the old code. It also requires adversarial inputs to finish in under 50 ms:[map:+ 50,000 tabs,[map:+ 50,000 spaces +x, 10,000 open[map:, a closed tag of 50,000 spaces,x+ 50,000 spaces +q, andx+ 50,000 tabs +up.Outputs are identical to before. A local differential run compared the new functions with verbatim copies of the old ones on 300,000 random tag texts and 300,000 exit words (Unicode spaces, line separators, BOM, lone surrogates, mixed case), plus every real set. All results matched. The new code finished every adversarial input in under 0.1 ms; the old code took 1–4.5 s.
Validation
pnpm checkpasses locallyCONTRIBUTING.mdAgent-run checks on
cb25a78fc(boxes left for the human reviewer):pnpm check: passed (format, lint, types and builds).node scripts/run-regressions.mjs --filterpassed forgame-dungeon-tags-redos(new),game-dungeon-maps,game-map-placesandgame-overworld-sites: 4/4.Manual verification notes
[map: kind="cave" name="Wolf Hollow"]still opens the cave map and[map: leave]still leaves it.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)UI evidence (if applicable)
None: no UI change.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.