diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-09-12 09:52:19 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-09-12 09:52:19 +0100 |
| commit | 62d4d33f71b17829f63d408ebe0f4c5eb560307e (patch) | |
| tree | f786edbedba8ef93f0b7aee61c1e51c7e94d6441 /lib/docx | |
| parent | dc49225425c2c07de0a6dc3529f2386c82a032b4 (diff) | |
Handle missing complex field start characters
Diffstat (limited to 'lib/docx')
| -rw-r--r-- | lib/docx/body-reader.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/docx/body-reader.js b/lib/docx/body-reader.js index 2ec9d0d..2c2a741 100644 --- a/lib/docx/body-reader.js +++ b/lib/docx/body-reader.js @@ -169,6 +169,12 @@ function BodyReader(options) { complexFieldStack.push({type: "begin", fldChar: element}); currentInstrText = []; } else if (type === "end") { + if (complexFieldStack.length === 0) { + return emptyResultWithMessages([warning( + "ignoring complex field end character without corresponding start character" + )]); + } + var complexFieldEnd = complexFieldStack.pop(); if (complexFieldEnd.type === "begin") { complexFieldEnd = parseCurrentInstrText(complexFieldEnd); @@ -179,6 +185,12 @@ function BodyReader(options) { })); } } else if (type === "separate") { + if (complexFieldStack.length === 0) { + return emptyResultWithMessages([warning( + "ignoring complex field separator character without corresponding start character" + )]); + } + var complexFieldSeparate = complexFieldStack.pop(); var complexField = parseCurrentInstrText(complexFieldSeparate); complexFieldStack.push(complexField); |
