mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
fix(parsers): never look up media on another computer's share (#7797)
* fix(parsers): never look up media on another computer's share A media src that names another computer's share (\\host\share\x.mp4, //host/share/x.mp4, file://host/share/x.mp4) or a device path was checked for existence before anything asked whether it was on the project's own drive. On Windows that check alone connects to the host and signs in with the user's credentials. The shared media resolver now treats such a src as missing without looking at it, unless it is on the share the project itself lives on. Render's containment filter, frame extraction, the audio mixer and the CLI media helpers all resolve through it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(parsers): keep the resolver's comment share at its baseline Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
477a3aea13
commit
2de5c027fa
@@ -235,7 +235,9 @@ export function resolveProjectRelativeSrc(
|
||||
const cleanSrc = fileUrlAsPath(cleanAssetUrl(src));
|
||||
|
||||
// A leading slash is an origin-root URL served from the project root, unless the absolute path exists.
|
||||
if (isAbsolute(cleanSrc) && existsSync(cleanSrc)) return cleanSrc;
|
||||
if (isAbsolute(cleanSrc) && !namesAnotherNetworkRoot(baseDir, cleanSrc) && existsSync(cleanSrc)) {
|
||||
return cleanSrc;
|
||||
}
|
||||
|
||||
const candidates = new Set<string>();
|
||||
for (const variant of decodeUrlPathVariants(cleanSrc)) {
|
||||
|
||||
@@ -15,6 +15,12 @@ vi.mock("node:fs", async () => {
|
||||
};
|
||||
return { ...fs, existsSync, default: { ...fs, existsSync } };
|
||||
});
|
||||
// file: URLs read as Windows reads them: file://host/share/x is \\host\share\x.
|
||||
vi.mock("node:url", async () => {
|
||||
const url = await vi.importActual<typeof import("node:url")>("node:url");
|
||||
const fileURLToPath = (href: string | URL) => url.fileURLToPath(href, { windows: true });
|
||||
return { ...url, fileURLToPath, default: { ...url, fileURLToPath } };
|
||||
});
|
||||
|
||||
const {
|
||||
localAbsoluteAssetFile,
|
||||
@@ -22,6 +28,7 @@ const {
|
||||
resolveAuthoredAssetFile,
|
||||
resolveCompositionSrc,
|
||||
resolveLocalAssetCandidates,
|
||||
resolveProjectRelativeSrc,
|
||||
srcOnAnotherNetworkRoot,
|
||||
} = await import("./assetResolution.js");
|
||||
const { resolve } = await import("node:path");
|
||||
@@ -167,3 +174,42 @@ describe("srcOnAnotherNetworkRoot under Windows rules", () => {
|
||||
expect(srcOnAnotherNetworkRoot("\\\\nas\\films\\project", "//NAS/films/voice.wav")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveProjectRelativeSrc under Windows rules", () => {
|
||||
const COMPILED = "C:\\project\\.hyperframes\\compiled";
|
||||
const onAShare = (path: string) => /^[\\/]{2}/.test(path);
|
||||
|
||||
it.each([
|
||||
["\\\\attacker.example\\share\\x.mp4", "\\\\attacker.example\\share\\x.mp4"],
|
||||
["//attacker.example/share/x.mp4", "//attacker.example/share/x.mp4"],
|
||||
["/\\attacker.example\\share\\x.mp4", "/\\attacker.example\\share\\x.mp4"],
|
||||
["file://attacker.example/share/x.mp4", "\\\\attacker.example\\share\\x.mp4"],
|
||||
["\\\\.\\pipe\\x", "\\\\.\\pipe\\x"],
|
||||
])("never looks at another computer's share for %s, even when it answers", (src, share) => {
|
||||
present.clear();
|
||||
present.add(share);
|
||||
touched.length = 0;
|
||||
const path = resolveProjectRelativeSrc(src, PROJECT, COMPILED);
|
||||
expect(touched.filter(onAShare)).toEqual([]);
|
||||
expect(onAShare(path)).toBe(false);
|
||||
});
|
||||
|
||||
it("finds a file on the share the project itself lives on", () => {
|
||||
present.clear();
|
||||
present.add("//NAS/films/shared/clip.mp4");
|
||||
expect(
|
||||
resolveProjectRelativeSrc("//NAS/films/shared/clip.mp4", "\\\\nas\\films\\project"),
|
||||
).toBe("//NAS/films/shared/clip.mp4");
|
||||
});
|
||||
|
||||
it("still finds a local absolute file", () => {
|
||||
present.clear();
|
||||
present.add("D:\\media\\clip.mp4");
|
||||
expect(resolveProjectRelativeSrc("D:\\media\\clip.mp4", PROJECT, COMPILED)).toBe(
|
||||
"D:\\media\\clip.mp4",
|
||||
);
|
||||
expect(resolveProjectRelativeSrc("file:///D:/media/clip.mp4", PROJECT)).toBe(
|
||||
"D:\\media\\clip.mp4",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user