[PR #4102] [MERGED] Fix the Clean HTML outgoing prompt regex #6233

Closed
opened 2026-10-23 04:08:26 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/4102
Author: @SpicyMarinara
Created: 7/25/2026
Status: ✅ Merged
Merged: 7/25/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/clean-html-outgoing-regex


📝 Commits (2)

  • c0aaca7 Start Clean HTML regex safety fix
  • 04a5ffe Fix Clean HTML outgoing prompt regex

📊 Changes

3 files changed (+123 additions, -3 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/server/src/db/seed-regex.ts (+24 -3)
📝 scripts/regressions/prompt.regression.ts (+98 -0)

📄 Description

Linked issue

Closes #4101

Why this change

  • The built-in Clean HTML (Outgoing Prompt) pattern nested unbounded quoted-attribute repeats inside another unbounded group. Marinara's ReDoS guard therefore rejected the default during editing and skipped it during prompt application, leaving HTML and <speaker> wrappers in context used by Immersive HTML, group Roleplay, and Agent workflows.

What changed

  • Replaced the nested-repeat expression with a validator-safe tag-oriented pattern that removes ordinary HTML/XML-style tags, group <speaker> wrappers, and doctypes.
  • Preserved the existing intentional exclusions for <font>, <lie>, <filter>, and HTML comments.
  • Added a startup migration that updates only the built-in default-clean-html row when its pattern is an exact match for the broken legacy default. Customized scripts and unrelated rows are not overwritten.
  • Added prompt regressions covering safety validation, save-schema acceptance, Immersive HTML markup, speaker cleanup, protected tags/comments, and migration boundaries.
  • Documented the fix in the Unreleased changelog.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

  • Automated validation performed: pnpm regression:prompt, pnpm check, and git diff --check.
  • The focused regression confirms the old default is rejected, the replacement passes the safety and save schemas, Immersive HTML and group speaker tags are removed from outgoing prompt text, protected tags/comments remain, and only the exact legacy built-in pattern qualifies for migration.
  • A human app walkthrough and container run remain to be performed.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

CHANGELOG.md includes the fix under Unreleased. No version-bearing files changed.

UI evidence (if applicable)

Not applicable; this is a prompt-cleanup and startup-migration fix.


🔄 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/Pasta-Devs/Marinara-Engine/pull/4102 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 7/25/2026 **Status:** ✅ Merged **Merged:** 7/25/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/clean-html-outgoing-regex` --- ### 📝 Commits (2) - [`c0aaca7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c0aaca758989b32d16ce5c6eeaa235a22ab6e4d8) Start Clean HTML regex safety fix - [`04a5ffe`](https://github.com/Pasta-Devs/Marinara-Engine/commit/04a5ffef83d4a6a644bde30e3b10992cd07ce557) Fix Clean HTML outgoing prompt regex ### 📊 Changes **3 files changed** (+123 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/server/src/db/seed-regex.ts` (+24 -3) 📝 `scripts/regressions/prompt.regression.ts` (+98 -0) </details> ### 📄 Description ## Linked issue Closes #4101 ## Why this change - The built-in **Clean HTML (Outgoing Prompt)** pattern nested unbounded quoted-attribute repeats inside another unbounded group. Marinara's ReDoS guard therefore rejected the default during editing and skipped it during prompt application, leaving HTML and `<speaker>` wrappers in context used by Immersive HTML, group Roleplay, and Agent workflows. ## What changed - Replaced the nested-repeat expression with a validator-safe tag-oriented pattern that removes ordinary HTML/XML-style tags, group `<speaker>` wrappers, and doctypes. - Preserved the existing intentional exclusions for `<font>`, `<lie>`, `<filter>`, and HTML comments. - Added a startup migration that updates only the built-in `default-clean-html` row when its pattern is an exact match for the broken legacy default. Customized scripts and unrelated rows are not overwritten. - Added prompt regressions covering safety validation, save-schema acceptance, Immersive HTML markup, speaker cleanup, protected tags/comments, and migration boundaries. - Documented the fix in the Unreleased changelog. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` ### Manual verification notes - Automated validation performed: `pnpm regression:prompt`, `pnpm check`, and `git diff --check`. - The focused regression confirms the old default is rejected, the replacement passes the safety and save schemas, Immersive HTML and group speaker tags are removed from outgoing prompt text, protected tags/comments remain, and only the exact legacy built-in pattern qualifies for migration. - A human app walkthrough and container run remain to be performed. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) `CHANGELOG.md` includes the fix under Unreleased. No version-bearing files changed. ## UI evidence (if applicable) Not applicable; this is a prompt-cleanup and startup-migration fix. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:08:26 +07:00
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
Pasta-Devs/Marinara-Engine#6233
No description provided.