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, 04:45 UTC
fix(web): RTF previews read Mac Roman documents (#39846)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
tiliakoos committed
Nov 20, 2026 at 20:23 UTC
524c757f827a869e42bf9e59ebb8c8cd4f0233d1
2 files changed
+8
-1
apps/web/src/components/files/FilePreviewPanel.test.ts
+5
@@ -245,6 +245,11 @@ Third}`;
245
const result = openRtf(input.buffer);
246
if (result.type !== "document") throw new Error("Expected document");
247
expect(result.pages[0]!.html).toBe("<p>А А<br>あ</p>");
248
+ for (const header of [String.raw`\mac`, String.raw`\mac\ansicpg10000`]) {
249
+ const mac = openRtf(bytes(String.raw`{\rtf1` + header + String.raw` Caf\'8e Cr\'8fme}`));
250
+ if (mac.type !== "document") throw new Error("Expected document");
251
+ expect(mac.pages[0]!.html).toBe("<p>Café Crème</p>");
252
+ }
253
expect(() => openRtf(bytes(String.raw`{\rtf1\ansicpg99999 text}`))).toThrow(
254
expect.objectContaining({ code: "rtf-code-page" }),
255
);
apps/web/src/components/files/extendedDocumentPreview.ts
+3
-1
@@ -685,7 +685,8 @@ export function openRtf(bytes: ArrayBuffer): OfficeWorkerResult {
685
if (!Number.isSafeInteger(arg) || arg < 0 || arg > source.length - i)
686
throw new PreviewError({ code: "rtf-binary-data" });
687
i += arg;
688
- } else if (word === "ansicpg") {
688
+ } else if (word === "mac") state.decoder = new TextDecoder("macintosh");
689
+ else if (word === "ansicpg") {
690
const label =
691
(
692
{
@@ -695,6 +696,7 @@ export function openRtf(bytes: ArrayBuffer): OfficeWorkerResult {
696
949: "euc-kr",
697
950: "big5",
698
874: "windows-874",
699
+ 10000: "macintosh",
700
} as Record<number, string>
701
)[arg] ?? `windows-${arg}`;
702
try {