Skip to content

The swiss army knife of lossless video/audio editing

Don't normalize absolute CLI file args

Claude71c01e12e7b4
diff --git a/src/main/util.test.ts b/src/main/util.test.ts
index 5c724e59..0cdfab83 100644
--- a/src/main/util.test.ts
+++ b/src/main/util.test.ts
@@ -1,6 +1,6 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { describe, expect, test } from 'vitest';
-import { join, resolve } from 'node:path';
+import { join, resolve, sep } from 'node:path';
import { resolveCliFileArgs } from './util';
@@ -12,8 +12,8 @@ describe('resolveCliFileArgs', () => {
expect(resolveCliFileArgs(['video.mp4', 'clips/a.mkv'], cwd)).toEqual([join(cwd, 'video.mp4'), join(cwd, 'clips', 'a.mkv')]);
});
- test('leaves absolute file args unchanged', () => {
- const absolute = resolve('/media/in/a.mp4');
+ test('leaves absolute file args untouched (no normalization, e.g. through symlinks)', () => {
+ const absolute = [resolve('/media/link'), '..', 'a.mp4'].join(sep);
expect(resolveCliFileArgs([absolute], cwd)).toEqual([absolute]);
});
});
diff --git a/src/main/util.ts b/src/main/util.ts
index 5a01857c..f3fc5acb 100644
--- a/src/main/util.ts
+++ b/src/main/util.ts
@@ -1,6 +1,6 @@
import { access, constants } from 'node:fs/promises';
import os from 'node:os';
-import { resolve } from 'node:path';
+import { isAbsolute, resolve } from 'node:path';
export const platform = os.platform();
export const arch = os.arch();
@@ -20,4 +20,4 @@ export async function pathExists(path: string) {
// File args forwarded from a second instance are relative to *its* cwd, not ours
// https://github.com/mifi/lossless-cut/issues/1571
-export const resolveCliFileArgs = (args: string[], workingDirectory: string) => args.map((arg) => resolve(workingDirectory, arg));
+export const resolveCliFileArgs = (args: string[], workingDirectory: string) => args.map((arg) => (isAbsolute(arg) ? arg : resolve(workingDirectory, arg)));