officeparser 7.2.1 → 7.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/defaults.js +4 -0
- package/dist/generators/ChunkingGenerator.js +1 -1
- package/dist/generators/HtmlGenerator.js +1 -1
- package/dist/officeparser.browser.d.ts +31 -1
- package/dist/officeparser.browser.iife.js +51 -51
- package/dist/officeparser.browser.mjs +51 -51
- package/dist/parsers/ExcelParser.js +1 -1
- package/dist/parsers/OpenOfficeParser.js +1 -1
- package/dist/parsers/PowerPointParser.js +1 -1
- package/dist/parsers/WordParser.js +1 -1
- package/dist/sbom.cdx.json +99 -99
- package/dist/types.d.ts +31 -1
- package/dist/types.js +8 -0
- package/dist/utils/configUtils.js +14 -2
- package/dist/utils/errorUtils.js +5 -1
- package/dist/utils/zipUtils.d.ts +2 -1
- package/dist/utils/zipUtils.js +34 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -751,6 +751,7 @@ Pass as the second argument to `parseOffice(file, config)`.
|
|
|
751
751
|
| `ignoreInternalLinks` | `boolean` | `false` | Strip bookmarks and internal cross-references from AST |
|
|
752
752
|
| `fileType` | `SupportedFileType \| null` | `null` | **Required for text-based binary data** (`'md'`, `'html'`, `'csv'`) as these lack magic bytes. |
|
|
753
753
|
| `csvDelimiter` | `string` | `','` | Input delimiter when parsing CSV files |
|
|
754
|
+
| `decompressionLimits` | `DecompressionLimits` | `{ maxUncompressedBytes: 512MB, maxZipEntries: 10000 }` | **New**: Limits applied during ZIP extraction to protect against excessive memory and resource usage |
|
|
754
755
|
| `pdfWorkerSrc` | `string` | CDN (jsDelivr) | Path/URL to `pdf.worker.min.mjs` (required in browser) |
|
|
755
756
|
| `onWarning` | `(issue: OfficeIssue) => void` | — | Callback for non-fatal parsing issues |
|
|
756
757
|
| `abortSignal` | `AbortSignal \| null` | `null` | Optional signal to cancel parsing (rejects with AbortError) |
|
package/dist/defaults.js
CHANGED
|
@@ -59,6 +59,10 @@ exports.DEFAULT_OFFICE_PARSER_CONFIG = {
|
|
|
59
59
|
ignoreInternalLinks: false,
|
|
60
60
|
fileType: null,
|
|
61
61
|
csvDelimiter: ',',
|
|
62
|
+
decompressionLimits: {
|
|
63
|
+
maxUncompressedBytes: 512 * 1024 * 1024,
|
|
64
|
+
maxZipEntries: 10000,
|
|
65
|
+
},
|
|
62
66
|
};
|
|
63
67
|
/**
|
|
64
68
|
* Default configuration for HTML generation.
|
|
@@ -644,7 +644,7 @@ class ChunkingGenerator extends BaseGenerator_js_1.BaseGenerator {
|
|
|
644
644
|
let timerId;
|
|
645
645
|
const timeoutPromise = new Promise((_, reject) => {
|
|
646
646
|
timerId = setTimeout(() => {
|
|
647
|
-
reject(
|
|
647
|
+
reject((0, errorUtils_js_1.getOfficeError)(types_js_1.OfficeErrorType.EMBEDDING_TIMEOUT, this.config, timeoutMs));
|
|
648
648
|
}, timeoutMs);
|
|
649
649
|
});
|
|
650
650
|
return Promise.race([call, timeoutPromise]).finally(() => {
|
|
@@ -469,7 +469,7 @@ class HtmlGenerator extends BaseGenerator_js_1.BaseGenerator {
|
|
|
469
469
|
src = `data:${attachment.mimeType || 'image/png'};base64,${attachment.data}`;
|
|
470
470
|
}
|
|
471
471
|
}
|
|
472
|
-
const img = `<img src="${src}" alt="${this.escape(node.text || meta?.altText || '')}"${className}${mappedAttrs}${styleAttr}>`;
|
|
472
|
+
const img = `<img src="${this.escape(src)}" alt="${this.escape(node.text || meta?.altText || '')}"${className}${mappedAttrs}${styleAttr}>`;
|
|
473
473
|
const content = this.config.includeFormatting ? `<div class="image-container">${img}<div class="caption">${this.escape(attachmentName || '')}</div></div>` : img;
|
|
474
474
|
return `${extraAnchors}<div${idAttr}>${content}</div>`;
|
|
475
475
|
}
|
|
@@ -34,7 +34,15 @@ export declare enum OfficeErrorType {
|
|
|
34
34
|
/** Semantic chunking strategy is selected but no embedding function is provided */
|
|
35
35
|
MISSING_EMBEDDING_FUNCTION = "MISSING_EMBEDDING_FUNCTION",
|
|
36
36
|
/** The operation was aborted */
|
|
37
|
-
OPERATION_ABORTED = "OPERATION_ABORTED"
|
|
37
|
+
OPERATION_ABORTED = "OPERATION_ABORTED",
|
|
38
|
+
/** ZIP entry count exceeds limit */
|
|
39
|
+
ZIP_ENTRY_COUNT_LIMIT_EXCEEDED = "ZIP_ENTRY_COUNT_LIMIT_EXCEEDED",
|
|
40
|
+
/** ZIP entry missing a valid declared size */
|
|
41
|
+
ZIP_ENTRY_INVALID_SIZE = "ZIP_ENTRY_INVALID_SIZE",
|
|
42
|
+
/** ZIP uncompressed size limit exceeded */
|
|
43
|
+
ZIP_SIZE_LIMIT_EXCEEDED = "ZIP_SIZE_LIMIT_EXCEEDED",
|
|
44
|
+
/** Embedding call timed out */
|
|
45
|
+
EMBEDDING_TIMEOUT = "EMBEDDING_TIMEOUT"
|
|
38
46
|
}
|
|
39
47
|
/**
|
|
40
48
|
* Standard warning types for OfficeParser.
|
|
@@ -349,6 +357,28 @@ export interface OfficeParserConfig {
|
|
|
349
357
|
* Defaults to ',' but can be overridden (e.g., ';', '\t').
|
|
350
358
|
*/
|
|
351
359
|
csvDelimiter?: string;
|
|
360
|
+
/**
|
|
361
|
+
* Limits and checks applied during ZIP extraction to protect against excessive
|
|
362
|
+
* memory and resource usage.
|
|
363
|
+
*/
|
|
364
|
+
decompressionLimits?: DecompressionLimits;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Limits applied to ZIP archive decompression.
|
|
368
|
+
*/
|
|
369
|
+
export interface DecompressionLimits {
|
|
370
|
+
/**
|
|
371
|
+
* Maximum allowed total uncompressed size (in bytes) of files extracted from a ZIP archive.
|
|
372
|
+
* Applies to OOXML (DOCX, XLSX, PPTX) and ODF (ODT, ODP, ODS) formats.
|
|
373
|
+
* Default is 536870912 (512 MB).
|
|
374
|
+
*/
|
|
375
|
+
maxUncompressedBytes?: number;
|
|
376
|
+
/**
|
|
377
|
+
* Maximum allowed number of entries (files and directories) in a ZIP archive.
|
|
378
|
+
* Applies to OOXML (DOCX, XLSX, PPTX) and ODF (ODT, ODP, ODS) formats.
|
|
379
|
+
* Default is 10000.
|
|
380
|
+
*/
|
|
381
|
+
maxZipEntries?: number;
|
|
352
382
|
}
|
|
353
383
|
/**
|
|
354
384
|
* Represents a single issue (warning, error, or info) generated during document processing.
|