From 9e447b70e261cbad205ed1343b53cfd6cad350a8 Mon Sep 17 00:00:00 2001 From: James Babcock Date: Thu, 20 Aug 2026 09:07:38 -0700 Subject: [PATCH] Fix a bug in the EvenHub emulator causing stray text at the end of containers --- app/apps/evenhub/session.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/apps/evenhub/session.ts b/app/apps/evenhub/session.ts index a6ba5f8c..7dadcdb9 100644 --- a/app/apps/evenhub/session.ts +++ b/app/apps/evenhub/session.ts @@ -788,9 +788,15 @@ export class EvenHubSession implements EvenHubMicClient, EvenHubImuClient, EvenH if (!container || container.kind !== "text") return false; const content = readString(data, "content", ""); const offset = readOptionalNumber(data, "contentOffset"); - const length = readOptionalNumber(data, "contentLength"); - if (offset !== undefined && length !== undefined) { - container.content = container.content.slice(0, offset) + content + container.content.slice(offset + length); + // (contentLength is intentionally ignored — see below.) + // Stock semantics are "write `content` at contentOffset and truncate the + // rest" (a null-terminating strcpy(buf+offset, content)), NOT a splice that + // keeps the old tail after offset+contentLength. Keeping the tail left stray + // trailing text when an app (e.g. g2oom) shrank a string with an + // under-sized contentLength; dropping it matches stock and still supports + // suffix rewrites (offset>0) and full replaces (offset 0 / omitted). + if (offset !== undefined && offset > 0) { + container.content = container.content.slice(0, offset) + content; } else { container.content = content; }