fix(producer): render compile never inlines private project files named by @font-face (#7925)

* fix(producer): render compile never inlines private project files named by @font-face

* fix(producer): a font link leading outside still warns before the private-file check
This commit is contained in:
Miguel Ángel
2026-11-16 06:35:51 +00:00
committed by GitHub
parent dac0468f70
commit 209477b658
2 changed files with 30 additions and 0 deletions
@@ -1556,6 +1556,35 @@ describe("system-primary font normalization", () => {
});
describe("local font embedding", () => {
it.each([".env", ".git/config", ".hyperframes/agent-handoff.json"])(
"never inlines the private project file %s that an @font-face url names",
async (file) => {
const projectDir = mkdtempSync(join(tmpdir(), "hf-private-font-"));
const secret = "HEYGEN_API_KEY=not-for-the-page";
mkdirSync(dirname(join(projectDir, file)), { recursive: true });
writeFileSync(join(projectDir, file), secret);
writeFileSync(
join(projectDir, "index.html"),
`<!DOCTYPE html>
<html><head><style>
@font-face { font-family: "P"; src: url("${file}"); }
</style></head><body>
<div data-composition-id="root" data-width="640" data-height="360" data-duration="1">Text</div>
</body></html>`,
);
const { html } = await compileForRender(
projectDir,
join(projectDir, "index.html"),
projectDir,
);
expect(html).not.toContain(Buffer.from(secret).toString("base64"));
expect(html).not.toContain("data:font/");
rmSync(projectDir, { recursive: true, force: true });
},
);
it("deduplicates assembled scene fonts before embedding and keeps the last descriptor order", async () => {
const projectDir = mkdtempSync(join(tmpdir(), "hf-repeated-scene-fonts-"));
mkdirSync(join(projectDir, "fonts"));
@@ -2009,6 +2009,7 @@ async function embedLocalFontFaces(
embeddedPaths.add(localPath);
continue;
}
if (isPrivateCompositionFile(projectDir, absPath)) continue;
const ext = absPath.match(/\.(woff2?|ttf|otf|ttc)$/i)?.[1]?.toLowerCase() ?? "ttf";
try {
if (fileBackedAbsolutePaths.has(absPath)) {