The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 16:00 UTC
fix(server): multi-line guest messages are no longer refused or stored with CRLF (#26542)
Julius Marminge committed
Nov 13, 2026 at 16:17 UTC
6bce2226decf0e5d1864fecb53e3e91ce1672acc
2 files changed
+28
-3
apps/server/src/guest/http.test.ts
+22
@@ -1,4 +1,5 @@
1
import * as NodeServices from "@effect/platform-node/NodeServices";
2
+import { GUEST_MESSAGE_MAX_LENGTH } from "@t3tools/contracts";
3
import { assert, it } from "@effect/vitest";
4
import * as Effect from "effect/Effect";
5
import { HttpServerRequest } from "effect/http";
@@ -26,3 +27,24 @@ it.effect("keeps a JSON file a guest attaches as a file, not a form field", () =
27
);
28
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
29
);
30
+
31
+it.effect("keeps a multi-line form message within the length limit as the guest typed it", () =>
32
+ Effect.gen(function* () {
33
+ // At the limit with LF, over it once each line break is counted as CRLF.
34
+ const lines = Array.from({ length: 50 }, () => "x".repeat(79));
35
+ const text = lines.join("\n").padEnd(GUEST_MESSAGE_MAX_LENGTH, "x");
36
+ const form = new FormData();
37
+ form.append("shareId", "share-1");
38
+ form.append("text", text);
39
+ const request = HttpServerRequest.fromWeb(
40
+ new Request("http://localhost/api/guest/messages?share=share-1", {
41
+ method: "POST",
42
+ body: form,
43
+ }),
44
+ );
45
+ const submission = yield* readSubmission.pipe(
46
+ Effect.provideService(HttpServerRequest.HttpServerRequest, request),
47
+ );
48
+ assert.strictEqual(submission?.fields.text, text);
49
+ }).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),
50
+);
apps/server/src/guest/http.ts
+6
-3
@@ -192,9 +192,12 @@ export const readSubmission = Effect.gen(function* () {
192
}),
193
),
194
);
195
- const fields = yield* decodeSubmit({ shareId: parts.shareId, text: parts.text ?? "" }).pipe(
196
- Effect.option,
197
- );
195
+ const text = parts.text ?? "";
196
+ const fields = yield* decodeSubmit({
197
+ shareId: parts.shareId,
198
+ // Form data sends every line break as CRLF; the textarea gave the guest LF.
199
+ text: typeof text === "string" ? text.replaceAll("\r\n", "\n") : text,
200
+ }).pipe(Effect.option);
201
if (fields._tag === "None") return null;
202
const files = parts.file;
203
const uploads: ReadonlyArray<GuestUpload> = Array.isArray(files)