exifreader 4.42.0 → 4.43.0

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/src/xmp-tags.js CHANGED
@@ -179,8 +179,11 @@ function getTextValue(node) {
179
179
  return node.nodeValue;
180
180
  }
181
181
 
182
+ // The elements object must not have a prototype. The element names come from
183
+ // the image, so an element named e.g. constructor would be found among the
184
+ // inherited properties, and one named __proto__ would replace the prototype.
182
185
  function getElementsFromNodes(nodes) {
183
- const elements = {};
186
+ const elements = Object.create(null);
184
187
 
185
188
  nodes.forEach((node) => {
186
189
  if (isElement(node)) {
@@ -284,7 +287,7 @@ function getLocalName(name) {
284
287
  function getDescription(value, name = undefined) {
285
288
  if (Array.isArray(value)) {
286
289
  const arrayDescription = getDescriptionOfArray(value);
287
- if ((name) && (typeof XmpTagNames[name] === 'function')) {
290
+ if (hasTagNameFunction(name)) {
288
291
  return XmpTagNames[name](value, arrayDescription);
289
292
  }
290
293
  return arrayDescription;
@@ -294,7 +297,7 @@ function getDescription(value, name = undefined) {
294
297
  }
295
298
 
296
299
  try {
297
- if ((name) && (typeof XmpTagNames[name] === 'function')) {
300
+ if (hasTagNameFunction(name)) {
298
301
  return XmpTagNames[name](value);
299
302
  }
300
303
  return decodeURIComponent(escape(value));
@@ -312,6 +315,12 @@ function getDescriptionOfArray(value) {
312
315
  }).join(', ');
313
316
  }
314
317
 
318
+ // The name comes from the image, so an inherited property of the tag name table
319
+ // must not be mistaken for a description function.
320
+ function hasTagNameFunction(name) {
321
+ return Object.prototype.hasOwnProperty.call(XmpTagNames, name) && (typeof XmpTagNames[name] === 'function');
322
+ }
323
+
315
324
  function getDescriptionOfObject(value) {
316
325
  const descriptions = [];
317
326