Skip to content

Commit d00a1d8

Browse files
authored
fix(deps): bump mammoth to 1.12.3 (#8568)
1 parent af88862 commit d00a1d8

3 files changed

Lines changed: 32 additions & 4 deletions

File tree

‎apps/sim/lib/file-parsers/parser-formats.test.ts‎

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function buildPptx(slideBodyXml: string, macroEnabled = false): Promise<Buffer>
4545
return zip.generateAsync({ type: 'nodebuffer' }) as Promise<Buffer>
4646
}
4747

48-
function buildDocx(bodyXml: string, macroEnabled = false): Promise<Buffer> {
48+
function buildDocx(bodyXml: string, macroEnabled = false, stylesXml?: string): Promise<Buffer> {
4949
const mainType = macroEnabled
5050
? 'application/vnd.ms-word.document.macroEnabled.main+xml'
5151
: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml'
@@ -62,6 +62,16 @@ function buildDocx(bodyXml: string, macroEnabled = false): Promise<Buffer> {
6262
'word/document.xml',
6363
`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:body>${bodyXml}</w:body></w:document>`
6464
)
65+
if (stylesXml) {
66+
zip.file(
67+
'word/_rels/document.xml.rels',
68+
`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/></Relationships>`
69+
)
70+
zip.file(
71+
'word/styles.xml',
72+
`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">${stylesXml}</w:styles>`
73+
)
74+
}
6575
return zip.generateAsync({ type: 'nodebuffer' }) as Promise<Buffer>
6676
}
6777

@@ -138,6 +148,24 @@ describe('DocxParser', () => {
138148
expect(error).toBeInstanceOf(FileParserError)
139149
expect(error).toMatchObject({ code: 'no_extractable_text' })
140150
})
151+
152+
it('ignores a style definition with an unrecognized type', async () => {
153+
const key = 'unrecognizedStyleType'
154+
const buffer = await buildDocx(
155+
'<w:p><w:r><w:t>Quarterly plan</w:t></w:r></w:p>',
156+
false,
157+
`<w:style w:type="__proto__" w:styleId="${key}"><w:name w:val="Custom"/></w:style>`
158+
)
159+
160+
try {
161+
const result = await new DocxParser().parseBuffer(buffer)
162+
163+
expect(result.content).toContain('Quarterly plan')
164+
expect(Object.hasOwn(Object.prototype, key)).toBe(false)
165+
} finally {
166+
delete (Object.prototype as Record<string, unknown>)[key]
167+
}
168+
})
141169
})
142170

143171
describe('OpenDocumentParser', () => {

‎apps/sim/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@
206206
"jszip": "3.10.1",
207207
"lib0": "0.2.117",
208208
"lru-cache": "11.3.6",
209-
"mammoth": "^1.9.0",
209+
"mammoth": "1.12.3",
210210
"marked": "18.0.11",
211211
"mermaid": "11.16.1",
212212
"micromatch": "4.0.8",

‎bun.lock‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)