From b8cb6f77d3bf049869fae51925417154fbdea036 Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Thu, 3 Dec 2026 23:00:44 +0100 Subject: [PATCH 1/3] test(server): DOCX body text survives an oversized footnote part Co-authored-by: Claude Opus 5.5 --- .../src/provider/userInputAttachments.test.ts | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/apps/server/src/provider/userInputAttachments.test.ts b/apps/server/src/provider/userInputAttachments.test.ts index 10adf6fa989b0..b48ee31f84895 100644 --- a/apps/server/src/provider/userInputAttachments.test.ts +++ b/apps/server/src/provider/userInputAttachments.test.ts @@ -1838,6 +1838,50 @@ describe("question answer paths", () => { exact: "The north region[Note: Inspect the seals.\nDo not reopen.] is ready. The south region[Note: Check power.] is ready.", }, + { + ext: "docx", + bounded: true, + parts: { + "word/document.xml": + '' + + "Findings at a glance." + + 'See the survey results.' + + "", + "word/_rels/document.xml.rels": + '' + + '' + + "", + "word/footnotes.xml": + '' + + ( + "" + + 'Sample recorded.'.repeat( + 5, + ) + + "" + ).repeat(6_500) + + "", + }, + expected: [ + "Findings at a glance.\nSee the survey results.", + "[Extracted text truncated at document extraction limits.]", + ], + }, + { + ext: "docx", + bounded: true, + parts: { + "word/document.xml": + 'Survey closed.Results follow.', + "word/_rels/document.xml.rels": + '', + "word/endnotes.xml": `Held in May.${"".repeat(199_995)}Sample.`, + }, + expected: [ + "Survey closed.[Note: Held in May.]\nResults follow.\n", + "[Extracted text truncated", + ], + }, { ext: "odt", parts: { From b2182aedd74f1b89d3e56bcb52f75fef0f22bf52 Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Thu, 3 Dec 2026 23:01:52 +0100 Subject: [PATCH 2/3] fix(server): a large footnote no longer erases a DOCX attachment's body text Co-authored-by: Claude Opus 5.5 --- apps/server/src/provider/documentTextWorker.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/server/src/provider/documentTextWorker.ts b/apps/server/src/provider/documentTextWorker.ts index 4b5002250eb28..88f95a3dcec14 100644 --- a/apps/server/src/provider/documentTextWorker.ts +++ b/apps/server/src/provider/documentTextWorker.ts @@ -1881,13 +1881,21 @@ async function* document(path: string, extension: string): AsyncGenerator(); - for (const note of all(read(notePath, styleRunHidden), kind)) { + // A cut part keeps the notes before the limit; the last one may be incomplete. + const notePart = readText(notePath, styleRunHidden); + const notes = [...all(notePart, kind)]; + if (notePart.truncated) { + notesCut = true; + notes.pop(); + } + for (const note of notes) { const body = Array.from(wordNoteParagraphs(note), (paragraph) => [...text(paragraph)].filter((part) => typeof part === "string").join(""), ) @@ -1929,6 +1937,7 @@ async function* document(path: string, extension: string): AsyncGenerator ({ common: new Map(), automatic: new Map() }); const odfTextStyles: OdfTextStyles | undefined = From 8df0736c3c5af59d7a6554fb1211e037a666ed97 Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Thu, 3 Dec 2026 23:11:45 +0100 Subject: [PATCH 3/3] fix(server): drop only the DOCX note left open at the XML node limit Co-authored-by: Claude Opus 5.5 --- apps/server/src/provider/documentTextWorker.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/apps/server/src/provider/documentTextWorker.ts b/apps/server/src/provider/documentTextWorker.ts index 88f95a3dcec14..2685b9dffe700 100644 --- a/apps/server/src/provider/documentTextWorker.ts +++ b/apps/server/src/provider/documentTextWorker.ts @@ -335,6 +335,8 @@ const PARTIAL_DROPPED = new Set([ "row", "tr", "table-row", + "footnote", + "endnote", ]); function xml( @@ -1888,14 +1890,9 @@ async function* document(path: string, extension: string): AsyncGenerator(); - // A cut part keeps the notes before the limit; the last one may be incomplete. - const notePart = readText(notePath, styleRunHidden); - const notes = [...all(notePart, kind)]; - if (notePart.truncated) { - notesCut = true; - notes.pop(); - } - for (const note of notes) { + const notes = readText(notePath, styleRunHidden); + notesCut ||= notes.truncated === true; + for (const note of all(notes, kind)) { const body = Array.from(wordNoteParagraphs(note), (paragraph) => [...text(paragraph)].filter((part) => typeof part === "string").join(""), )