diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-08-28 17:30:31 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-08-28 17:30:31 +0100 |
| commit | 2888fa158d67c1419199f152326e12a05618b53e (patch) | |
| tree | c239ed44678ba87f29ff9b84625cf1a0ba48a68a /lib/docx/content-types-reader.js | |
| parent | 31f0c370be4b95ac4fa285fea3be970606735f16 (diff) | |
Create objects without prototypes when used as map with arbitrary keys
Diffstat (limited to 'lib/docx/content-types-reader.js')
| -rw-r--r-- | lib/docx/content-types-reader.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/docx/content-types-reader.js b/lib/docx/content-types-reader.js index 8233119..adb45a6 100644 --- a/lib/docx/content-types-reader.js +++ b/lib/docx/content-types-reader.js @@ -14,9 +14,9 @@ exports.defaultContentTypes = contentTypes({}, {}); function readContentTypesFromXml(element) { - var extensionDefaults = {}; - var overrides = {}; - + var extensionDefaults = Object.create(null); + var overrides = Object.create(null); + element.children.forEach(function(child) { if (child.name === "content-types:Default") { extensionDefaults[child.attributes.Extension] = child.attributes.ContentType; @@ -41,7 +41,7 @@ function contentTypes(overrides, extensionDefaults) { } else { var pathParts = path.split("."); var extension = pathParts[pathParts.length - 1]; - if (extensionDefaults.hasOwnProperty(extension)) { + if (Object.prototype.hasOwnProperty.call(extensionDefaults, extension)) { return extensionDefaults[extension]; } else { var fallback = fallbackContentTypes[extension.toLowerCase()]; @@ -54,5 +54,5 @@ function contentTypes(overrides, extensionDefaults) { } } }; - + } |
