exifreader
Advanced tools
Comparing version 4.12.1 to 4.13.0
{ | ||
"name": "exifreader", | ||
"version": "4.12.1", | ||
"version": "4.13.0", | ||
"description": "Library that parses Exif metadata in images.", | ||
@@ -5,0 +5,0 @@ "author": "Mattias Wallander <mattias@wallander.eu>", |
@@ -11,6 +11,13 @@ /* This Source Code Form is subject to the terms of the Mozilla Public | ||
if (typeof DOMParser !== 'undefined') { | ||
return DOMParser; | ||
return new DOMParser(); | ||
} | ||
try { | ||
return __non_webpack_require__('@xmldom/xmldom').DOMParser; // eslint-disable-line no-undef | ||
// eslint-disable-next-line no-undef | ||
return new (__non_webpack_require__('@xmldom/xmldom').DOMParser)({ | ||
errorHandler: { | ||
error: () => { | ||
throw new Error('Faulty XML'); | ||
} | ||
} | ||
}); | ||
} catch (error) { | ||
@@ -17,0 +24,0 @@ return undefined; |
@@ -14,6 +14,27 @@ /* This Source Code Form is subject to the terms of the Mozilla Public | ||
function read(dataView, chunks) { | ||
const tags = {}; | ||
if (typeof dataView === 'string') { | ||
return readTags({}, dataView); | ||
readTags(tags, dataView); | ||
return tags; | ||
} | ||
return extractCompleteChunks(dataView, chunks).reduce(readTags, {}); | ||
const [standardXmp, extendedXmp] = extractCompleteChunks(dataView, chunks); | ||
const hasStandardTags = readTags(tags, standardXmp); | ||
if (extendedXmp) { | ||
const hasExtendedTags = readTags(tags, extendedXmp); | ||
if (!hasStandardTags && !hasExtendedTags) { | ||
// Some writers are not spec-compliant in that they split an XMP | ||
// metadata tree over both the standard XMP block and the extended | ||
// XMP block. If we failed parsing both of the XMPs in the regular | ||
// way, we try to combine them to see if that works better. | ||
delete tags._raw; | ||
readTags(tags, combineChunks(dataView, chunks)); | ||
} | ||
} | ||
return tags; | ||
} | ||
@@ -58,5 +79,6 @@ | ||
return objectAssign(tags, parseXMPObject(convertToObject(rdf, true))); | ||
objectAssign(tags, parseXMPObject(convertToObject(rdf, true))); | ||
return true; | ||
} catch (error) { | ||
return tags; | ||
return false; | ||
} | ||
@@ -66,4 +88,4 @@ } | ||
function getDocument(chunkDataView) { | ||
const Parser = DOMParser.get(); | ||
if (!Parser) { | ||
const domParser = DOMParser.get(); | ||
if (!domParser) { | ||
console.warn('Warning: DOMParser is not available. It is needed to be able to parse XMP tags.'); // eslint-disable-line no-console | ||
@@ -73,3 +95,2 @@ throw new Error(); | ||
const domParser = new Parser(); | ||
const xmlString = typeof chunkDataView === 'string' ? chunkDataView : getStringFromDataView(chunkDataView, 0, chunkDataView.byteLength); | ||
@@ -76,0 +97,0 @@ const doc = domParser.parseFromString(trimXmlSource(xmlString), 'application/xml'); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
580761
5944