Skip to content

Commit 718c67b

Browse files
fix: escape NUL bytes in HFMASK regex (Bun blank renders) + Windows junction for studio preview links (#2140)
* fix(core): escape NUL delimiters in HFMASK mask token and restore regex Raw 0x00 bytes in the maskInertRegions token and restore regex made timingCompiler.ts binary to git and shipped raw NULs into dist/cli.js. Bun's transpiler (<= 1.3.11) corrupts raw NULs in regex literals into literal backslash-uFFFD text, so restore never matched: every masked <style>/<script> region was dropped, the player never initialized, and bunx renders produced blank white frames showing HFMASK tokens. Use \u0000 escapes instead, which survive any transpile layer, and add a byte-level regression test (behavior is identical under Node, so only a byte check catches this). Fixes the first half of #2139. * fix(cli): use NTFS junctions for studio project links on Windows linkProjectIntoStudioData called symlinkSync(dir, path, "dir"), which needs Developer Mode or elevation on Windows, so preview and dev in local-studio mode died with EPERM for default-configured users. Junctions need no privilege, work for directories, and keep the live write-back the studio depends on (a copy fallback would decouple the studio from the real project). Covers both preview and dev, which share the helper. Fixes the second half of #2139.
1 parent 6152437 commit 718c67b

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎packages/cli/src/commands/preview.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,9 @@ function linkProjectIntoStudioData(
682682
}
683683
}
684684
if (!existsSync(symlinkPath)) {
685-
symlinkSync(dir, symlinkPath, "dir");
685+
// Windows: "dir" symlinks need Developer Mode or elevation (EPERM otherwise);
686+
// NTFS junctions are unprivileged and keep the live write-back the studio needs.
687+
symlinkSync(dir, symlinkPath, process.platform === "win32" ? "junction" : "dir");
686688
createdSymlink = true;
687689
}
688690
}

‎packages/core/src/compiler/timingCompiler.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { readFileSync } from "node:fs";
2+
import { dirname, join } from "node:path";
13
import { describe, it, expect } from "vitest";
24
import {
35
compileTimingAttrs,
@@ -6,6 +8,15 @@ import {
68
clampDurations,
79
} from "./timingCompiler.js";
810

11+
// Raw 0x00 bytes in the HFMASK delimiters shipped once and broke every render
12+
// under Bun's transpiler while behaving fine under Node (issue #2139) — only a
13+
// byte-level check catches that, so keep the delimiters as \x00 escapes.
14+
it("source contains no raw NUL bytes", () => {
15+
const testPath = expect.getState().testPath ?? "";
16+
const src = readFileSync(join(dirname(testPath), "timingCompiler.ts"), "latin1");
17+
expect(src.includes("\x00")).toBe(false);
18+
});
19+
920
describe("compileTimingAttrs", () => {
1021
it("adds data-end when data-start and data-duration are present on a video", () => {
1122
const html = '<video id="v1" src="a.mp4" data-start="2" data-duration="5">';
308 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)