diff --git a/apps/server/src/provider/documentTextWorker.ts b/apps/server/src/provider/documentTextWorker.ts index 4b5002250eb2..2685b9dffe70 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( @@ -1881,13 +1883,16 @@ async function* document(path: string, extension: string): AsyncGenerator(); - for (const note of all(read(notePath, styleRunHidden), kind)) { + 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(""), ) @@ -1929,6 +1934,7 @@ async function* document(path: string, extension: string): AsyncGenerator ({ common: new Map(), automatic: new Map() }); const odfTextStyles: OdfTextStyles | undefined = diff --git a/apps/server/src/provider/userInputAttachments.test.ts b/apps/server/src/provider/userInputAttachments.test.ts index 10adf6fa989b..b48ee31f8489 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: {