fix(producer): a clip whose file name has a space or accent is mixed into the export once (#7747)

* fix(producer): a clip whose file name has a space or accent is mixed into the export once

* fix(producer): compare a clip's src decoded, keeping the authored spelling either way
This commit is contained in:
Miguel Ángel
2026-11-14 16:18:22 +00:00
committed by GitHub
parent a92498b903
commit a3fa250b25
4 changed files with 70 additions and 20 deletions
+5 -18
View File
@@ -32,6 +32,7 @@ import { fpsToNumber, type Fps } from "@hyperframes/core";
import { stripSdrPngColourTags } from "@hyperframes/core/compiler/png-colour-tags";
import { openRangeEnd } from "@hyperframes/studio-server/media-range";
import { getVerifiedHyperframeRuntimeSource } from "./hyperframeRuntimeLoader.js";
import { servedPath } from "./servedPath.js";
import { getHfEarlyStub } from "../generated/hf-early-stub-inline.js";
import { defaultLogger, type ProducerLogger } from "../logger.js";
import { refusesOutsideLink } from "../utils/paths.js";
@@ -819,25 +820,11 @@ export function createFileServer(options: FileServerOptions): Promise<FileServer
let requestPath = c.req.path;
if (requestPath === "/") requestPath = "/index.html";
const relativePath = requestPath
.replace(/^\//, "")
.split("/")
.map((seg) => {
try {
return decodeURIComponent(seg);
} catch {
return seg;
}
})
.join("/");
const relativePath = servedPath(requestPath);
// Resolve against compiledDir first (preferred — overrides project files
// for compositions emitted by the build), then projectDir as fallback.
// Each candidate is rejected if `..` segments push it outside the
// intended root: `path.join` normalizes traversal but does not enforce
// containment, so a request like `GET /../etc/passwd` would otherwise
// be served straight off the filesystem. compiledDir stays lexical: it
// links extracted frame directories in from the work directory.
// compiledDir (the build's output) wins over projectDir. A candidate `..` pushes outside its root is
// rejected: `path.join` does not enforce containment, so `GET /../etc/passwd` would be served.
// compiledDir stays lexical: it links extracted frame directories in from the work directory.
let file: ReturnType<typeof openRegularFile> = null;
for (const root of compiledDir ? [compiledDir, projectDir] : [projectDir]) {
const candidate = join(root, relativePath);
@@ -826,6 +826,54 @@ describe("runProbeStage — forceScreenshot threading", () => {
expect(mediaPreflightComposition).toBe(input.composition);
});
it.each(["take one.mp4", "café.mp4", "take%20one.mp4", "caf%C3%A9.mp4"])(
"mixes the sound of a clip whose src is written %s once, however the browser spells it",
async (name) => {
resetRetryMocks();
const timing = { start: 0, end: 5, duration: 5, mediaStart: 0, loop: false, volume: 1 };
browserMediaResults = [
{
id: "clip",
tagName: "video",
src: new URL(name, "http://127.0.0.1:0/").href,
hasAudio: true,
muted: false,
...timing,
},
];
const { runProbeStage } = await import("./probeStage.js");
const { appendAutoDetectedVideoAudio } = await import("./extractVideosStage.js");
const input = makeProbeInput({});
input.composition.duration = 5;
input.composition.videos.push({
id: "clip",
src: name,
start: 0,
end: 5,
mediaStart: 0,
loop: false,
hasAudio: true,
});
input.composition.audios.push({
id: videoAudioId("clip"),
src: name,
start: 0,
end: 5,
mediaStart: 0,
layer: 0,
type: "video",
});
await runProbeStage({ ...input, measuresShownBoxes: true });
appendAutoDetectedVideoAudio(input.composition, [
{ videoId: "clip", metadata: { hasAudio: true } },
]);
expect(input.composition.videos[0]?.src).toBe(name);
expect(input.composition.audios.map((audio) => audio.id)).toEqual([videoAudioId("clip")]);
},
);
it("uses selected intrinsic duration only when the variable-bound duration was inferred", async () => {
resetRetryMocks();
const media = (
@@ -73,6 +73,7 @@ import {
type FileServerHandle,
VIRTUAL_TIME_SHIM,
} from "../../fileServer.js";
import { servedPath } from "../../servedPath.js";
import type { ProducerLogger } from "../../../logger.js";
import {
BROWSER_MEDIA_EPSILON,
@@ -668,7 +669,7 @@ export async function runProbeStage(input: ProbeStageInput): Promise<ProbeStageR
// Reconcile to browser/runtime media metadata (runtime src can differ from static HTML).
const existing = composition.videos.find((v) => v.id === el.id);
if (existing) {
const sourceChanged = existing.src !== src;
const sourceChanged = servedPath(existing.src) !== servedPath(src);
if (sourceChanged) {
existing.src = src;
}
@@ -718,7 +719,7 @@ export async function runProbeStage(input: ProbeStageInput): Promise<ProbeStageR
if (existingAudioIds.has(el.id)) {
const existing = composition.audios.find((a) => a.id === el.id);
if (existing) {
const sourceChanged = existing.src !== src;
const sourceChanged = servedPath(existing.src) !== servedPath(src);
if (sourceChanged) {
existing.src = src;
}
@@ -0,0 +1,14 @@
/** The project-relative path a render file server URL path names: each segment decoded, as the browser encoded it. */
export function servedPath(urlPath: string): string {
return urlPath
.replace(/^\//, "")
.split("/")
.map((seg) => {
try {
return decodeURIComponent(seg);
} catch {
return seg;
}
})
.join("/");
}