mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #7346] [MERGED] feat(characters): save greeting web images to the gallery on request #7693
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#7693
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/7346
Author: @SpicyMarinara
Created: 10/9/2026
Status: ✅ Merged
Merged: 10/9/2026
Merged by: @SpicyMarinara
Base:
staging← Head:feat/7221-bake-greeting-images📝 Commits (8)
d5b3a50feat(characters): save greeting web images to the gallery on request421ac44Merge origin/staging into feat/7221-bake-greeting-imagesa6b3254fix(characters): keep server paths out of greeting bake errors378001ffix(characters): declare the bake route's rate limit and build gallery paths from the stored idfb55e4eMerge origin/staging into feat/7221-bake-greeting-images3138003fix(characters): restore baked greeting links in compatible profile exportsc817bd1Merge origin/staging into feat/7221-bake-greeting-images7fae8ddMove the CHANGELOG entry away from other open PRs📊 Changes
17 files changed (+705 additions, -12 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
docs/characters/creating-and-editing-characters.md(+2 -0)📝
docs/characters/galleries.md(+8 -0)📝
packages/client/src/components/characters/CharacterEditor.tsx(+100 -3)📝
packages/client/src/components/characters/CharacterLibraryView.tsx(+5 -1)📝
packages/client/src/components/chat/ChatMessage.tsx(+4 -4)📝
packages/client/src/hooks/use-characters.ts(+30 -0)📝
packages/client/src/lib/card-asset-links.ts(+13 -0)📝
packages/client/src/localization/locales/en.json(+10 -0)📝
packages/server/src/middleware/rate-limit.ts(+14 -0)📝
packages/server/src/routes/backup.routes.ts(+4 -1)📝
packages/server/src/routes/characters.routes.ts(+57 -0)➕
packages/server/src/services/image/greeting-image-bake.ts(+60 -0)📝
packages/server/src/utils/security.ts(+6 -3)📝
packages/shared/src/index.ts(+1 -0)➕
packages/shared/src/utils/greeting-image-bake.ts(+122 -0)➕
scripts/regressions/greeting-image-bake.regression.ts(+268 -0)📄 Description
Linked issue
Closes #7221
Why this change
What changed
or HTML<img src="https://…">), a Save images locally button appears. It downloads them into the character's Gallery and rewrites each reference to the portablecard://self/gallery/<file>form, recording the original link inextensions.bakedGreetingImages. The form becomes dirty; the user saves as usual. Restore web links puts the original links back. Nothing is fetched automatically.POST /api/characters/:id/gallery/bake(same plugin and auth as the other character gallery routes; own rate-limit bucket of 20/min; at most 10 URLs per request, the client batches): downloads through the existingsafeFetchguard — http/https only, every redirect hop re-validated (max 3), the checked DNS answer pinned for the connection, private/loopback/link-local/CGNAT/ULA/mapped/reserved addresses refused, no cookies or auth forwarded, 15 s timeout, 10 MB response cap. Only PNG/JPEG/GIF/WebP by magic bytes are kept (SVG, HTML and AVIF rejected), with a 40-megapixel cap. Files get app-generated names (<nanoid>.<ext>) in the character's gallery folder and a gallery row, so character delete and native export already handle them..marinara.jsonexports carry the gallery with filenames, so thecard://selfrefs survive import. Compatible JSON / PNG cards carry no gallery, sobuildCompatibleCharacterExportnow restores the original web links for baked images.<img src="card://…">in HTML greetings/messages now resolves before DOMPurify drops the unknowncard:scheme (markdown images already did).safeFetch): the built-in private ranges stay blocked whenTRUSTED_PRIVATE_NETWORKSnarrows the sign-in trust list (before, e.g.TRUSTED_PRIVATE_NETWORKS=192.168.1.0/24let outbound fetches reach10.xand169.254.169.254), and IPv6 multicast (ff00::/8) and IPv4-compatible (::/96, e.g.::7f00:1) addresses are refused. This only blocks more; callers that need local hosts keep their explicitallowLocalflags.docs/characters/galleries.md(new "Save web images from greetings" subsection) and a pointer indocs/characters/creating-and-editing-characters.md. Translations tracked in #7345.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
shows Save images locally under Dialogue & Greetings, and that a character without web images shows no button.card://self/gallery/<id>.png, the image appears in the Gallery tab, and the greeting preview and a new chat's greeting still show the image after saving the character.<img width="300" src="https://…">) keeps its attributes after baking and renders in a new chat..svgimage,http://127.0.0.1/…) leaves that link unchanged and shows an error toast with the reason.Agent-run checks:
pnpm check(via the shared slot limiter) passed;node ./scripts/run-regressions.mjs --filter scripts/regressions/greeting-image-bakepassed (shared helpers, image validation, network guard incl.TRUSTED_PRIVATE_NETWORKSnarrowing, redirect to loopback, route with a stubbed public host, 10-URL cap, 404, compatible export, HTMLcard://resolution, hostile-input regex timing); confirmed the new regression fails against the unhardenedsecurity.ts. Also re-ran the existingimage-result-url-security,provider-compat,extension-security,swarmui-video-origin,opencode-session,open-issues,code-scanning-content-parsing, all*security*,request-timeouts,docker-proxy-auth,capability-package-cache,experience-*,best-effort,decision-local-models,sidecar-local-gguf,logging-failure-linesandmari-edit-flow-revertregressions: all passed.pnpm localization:checkpassed. Local CodeRabbit (committed changes against staging) reported 1 finding: per-URL errors could echo filesystem/storage error messages (server paths) to the client. Fixed ina6b32546a: storage failures now return a plain message and only download errors reach the client;pnpm checkre-run and passed afterwards. No browser click-through was done.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)CHANGELOG
[Unreleased]entry added; English docs updated; translation follow-up: #7345.UI evidence (if applicable)
Not captured by the agent.
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.