Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@eris/exif

Package Overview
Dependencies
Maintainers
1
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eris/exif - npm Package Compare versions

Comparing version 0.4.2-alpha.20 to 0.4.2-alpha.21

1

dist/encoder/xmp-encoder.d.ts

@@ -7,2 +7,3 @@ import { IGenericMetadata, IBufferLike } from '../utils/types';

static encode(metadata: IGenericMetadata, original?: IBufferLike): IBufferLike;
private static _ensureRdfDescription;
private static _processEntry;

@@ -9,0 +10,0 @@ private static _findWithRegex;

47

dist/encoder/xmp-encoder.js

@@ -13,5 +13,3 @@ "use strict";

const log = log_1.createLogger('xmp-encoder');
const XMP_BASE_FILE = `
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.6-c140 79.160451, 2017/05/06-01:08:21">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
const XMP_BASE_RDF_DESCRIPTION = `
<rdf:Description rdf:about=""

@@ -21,10 +19,13 @@ xmlns:xmp="http://ns.adobe.com/xap/1.0/"

xmlns:exif="http://ns.adobe.com/exif/1.0/"
xmlns:aux="http://ns.adobe.com/exif/1.0/aux/"
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/"
xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/"
xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:crs="http://ns.adobe.com/camera-raw-settings/1.0/">
xmlns:dc="http://purl.org/dc/elements/1.1/">
</rdf:Description>
</rdf:RDF>
`.trim();
const XMP_BASE_RDF = `
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
${XMP_BASE_RDF_DESCRIPTION}
</rdf:RDF>
`.trim();
const XMP_BASE_FILE = `
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.6-c140 79.160451, 2017/05/06-01:08:21">
${XMP_BASE_RDF}
</x:xmpmeta>

@@ -58,4 +59,3 @@ `.trim();

static encode(metadata, original) {
let xmpData = (original || XMP_BASE_FILE).toString();
let extraLength = 0;
let { xmpData, extraLength } = XMPEncoder._ensureRdfDescription(original);
for (const key of Object.keys(metadata)) {

@@ -90,2 +90,25 @@ const tagName = key;

}
static _ensureRdfDescription(original) {
let xmpData = (original || XMP_BASE_FILE).toString();
let extraLength = 0;
// It already has an rdf:Description, no need to do anything else.
if (xmpData.includes('<rdf:Description')) {
return { xmpData, extraLength };
}
// It's missing a description but has an rdf:RDF, just inject the description.
if (xmpData.includes('</rdf:RDF>')) {
const newData = xmpData.replace(/(\s*)<\/rdf:RDF>/, `${XMP_BASE_RDF_DESCRIPTION}$1</rdf:RDF>`);
extraLength += newData.length - xmpData.length;
xmpData = newData;
return { xmpData, extraLength };
}
// It's missing rdf:RDf completely, inject everything
if (xmpData.includes('</x:xmpmeta>')) {
const newData = xmpData.replace(/(\s*)<\/x:xmpmeta>/, `${XMP_BASE_RDF}$1</x:xmpmeta>`);
extraLength += newData.length - xmpData.length;
xmpData = newData;
return { xmpData, extraLength };
}
throw new Error(`XMP data did not contain any discernible rdf markers:\n${xmpData}`);
}
static _processEntry(xmpData, tagName, value) {

@@ -92,0 +115,0 @@ log(`processing ${tagName}`);

@@ -24,5 +24,3 @@ import {IGenericMetadata, IBufferLike, XMPTagName} from '../utils/types'

const XMP_BASE_FILE = `
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.6-c140 79.160451, 2017/05/06-01:08:21">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
const XMP_BASE_RDF_DESCRIPTION = `
<rdf:Description rdf:about=""

@@ -32,10 +30,15 @@ xmlns:xmp="http://ns.adobe.com/xap/1.0/"

xmlns:exif="http://ns.adobe.com/exif/1.0/"
xmlns:aux="http://ns.adobe.com/exif/1.0/aux/"
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/"
xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/"
xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:crs="http://ns.adobe.com/camera-raw-settings/1.0/">
xmlns:dc="http://purl.org/dc/elements/1.1/">
</rdf:Description>
</rdf:RDF>
`.trim()
const XMP_BASE_RDF = `
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
${XMP_BASE_RDF_DESCRIPTION}
</rdf:RDF>
`.trim()
const XMP_BASE_FILE = `
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.6-c140 79.160451, 2017/05/06-01:08:21">
${XMP_BASE_RDF}
</x:xmpmeta>

@@ -77,4 +80,3 @@ `.trim()

public static encode(metadata: IGenericMetadata, original?: IBufferLike): IBufferLike {
let xmpData = (original || XMP_BASE_FILE).toString()
let extraLength = 0
let {xmpData, extraLength} = XMPEncoder._ensureRdfDescription(original)

@@ -115,2 +117,32 @@ for (const key of Object.keys(metadata)) {

private static _ensureRdfDescription(
original: IBufferLike | undefined,
): {xmpData: string; extraLength: number} {
let xmpData = (original || XMP_BASE_FILE).toString()
let extraLength = 0
// It already has an rdf:Description, no need to do anything else.
if (xmpData.includes('<rdf:Description')) {
return {xmpData, extraLength}
}
// It's missing a description but has an rdf:RDF, just inject the description.
if (xmpData.includes('</rdf:RDF>')) {
const newData = xmpData.replace(/(\s*)<\/rdf:RDF>/, `${XMP_BASE_RDF_DESCRIPTION}$1</rdf:RDF>`)
extraLength += newData.length - xmpData.length
xmpData = newData
return {xmpData, extraLength}
}
// It's missing rdf:RDf completely, inject everything
if (xmpData.includes('</x:xmpmeta>')) {
const newData = xmpData.replace(/(\s*)<\/x:xmpmeta>/, `${XMP_BASE_RDF}$1</x:xmpmeta>`)
extraLength += newData.length - xmpData.length
xmpData = newData
return {xmpData, extraLength}
}
throw new Error(`XMP data did not contain any discernible rdf markers:\n${xmpData}`)
}
private static _processEntry(

@@ -117,0 +149,0 @@ xmpData: string,

{
"name": "@eris/exif",
"version": "0.4.2-alpha.20",
"version": "0.4.2-alpha.21",
"description": "Parses EXIF data.",

@@ -41,3 +41,3 @@ "main": "./dist/index.js",

},
"gitHead": "c6ba7596a97d36f68fbadcdf0ccaf3e951277ca2"
"gitHead": "4e2cc9ff9520818223b0f956c59900b31525ea56"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc