Skip to content

Commit

Permalink
edit-meta: fail fast for forbidden mimes
Browse files Browse the repository at this point in the history
Signed-off-by: Varun Patil <[email protected]>
  • Loading branch information
pulsejet committed Oct 30, 2023
1 parent 32e9105 commit 3be478b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/Exif.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class Exif
{
private const FORBIDDEN_EDIT_MIMES = ['image/bmp', 'image/x-dcraw', 'video/MP2T'];
private const FORBIDDEN_EDIT_MIMES = ['image/bmp', 'image/x-dcraw', 'video/MP2T']; // also update const.ts
private const EXIFTOOL_TIMEOUT = 30000;
private const EXIFTOOL_ARGS = ['-api', 'QuickTimeUTC=1', '-n', '-json'];

Expand Down
12 changes: 12 additions & 0 deletions src/components/modal/EditMetadataModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,18 @@ export default defineComponent({
let done = 0;
this.progress = 0;
// Filter out forbidden MIME types
photos = photos.filter((p) => {
if (this.c.FORBIDDEN_EDIT_MIMES.includes(p.mimetype ?? String())) {
showWarning(
this.t('memories', 'Cannot edit {name} of type {type}', { name: p.basename!, type: p.mimetype! }),
);
return false;
}
return true;
});
// Load metadata for all photos
const calls = photos.map((p) => async () => {
try {
Expand Down
4 changes: 2 additions & 2 deletions src/services/utils/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { IPhoto } from '@typings';

/** Global constants */
export const constants = Object.freeze({
// Flags for photos
FLAG_PLACEHOLDER: 1 << 0,
FLAG_LOAD_FAIL: 1 << 1,
FLAG_IS_VIDEO: 1 << 2,
Expand All @@ -12,9 +11,10 @@ export const constants = Object.freeze({
FLAG_LEAVING: 1 << 5,
FLAG_IS_LOCAL: 1 << 6,

// Special strings
FACE_NULL: 'NULL',

MIME_RAW: 'image/x-dcraw',
FORBIDDEN_EDIT_MIMES: ['image/bmp', 'image/x-dcraw', 'video/MP2T'], // Exif.php
});

/**
Expand Down

0 comments on commit 3be478b

Please sign in to comment.