diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-08-28 14:39:48 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-08-28 14:39:48 +0100 |
| commit | 31f0c370be4b95ac4fa285fea3be970606735f16 (patch) | |
| tree | c774a0195cb32e8ff95632f72630a7ca15306fef /lib | |
| parent | e3b9cecdaa3df0d9007ed7b06add53c65516e429 (diff) | |
Avoid prototype pollution when reading styles
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/docx/styles-reader.js | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/docx/styles-reader.js b/lib/docx/styles-reader.js index 28c809b..276a668 100644 --- a/lib/docx/styles-reader.js +++ b/lib/docx/styles-reader.js @@ -27,16 +27,27 @@ function readStylesXml(root) { var tableStyles = {}; var numberingStyles = {}; - var styles = { - "paragraph": paragraphStyles, - "character": characterStyles, - "table": tableStyles, - "numbering": numberingStyles - }; - root.getElementsByTagName("w:style").forEach(function(styleElement) { var style = readStyleElement(styleElement); - var styleSet = styles[style.type]; + var styleSet; + + switch (style.type) { + case "paragraph": + styleSet = paragraphStyles; + break; + + case "character": + styleSet = characterStyles; + break; + + case "table": + styleSet = tableStyles; + break; + + case "numbering": + styleSet = numberingStyles; + break; + } // Per 17.7.4.17 style (Style Definition) of ECMA-376 4th edition Part 1: // |
