Skip to content

Commit da0c8da

Browse files
committed
og_image: Clear environment variables for typst subprocess
1 parent 90bb5b9 commit da0c8da

File tree

1 file changed

+11
-0
lines changed
  • crates/crates_io_og_image/src

1 file changed

+11
-0
lines changed

crates/crates_io_og_image/src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,17 @@ impl OgImageGenerator {
251251
// Pass input and output file paths
252252
command.arg(&typ_file_path).arg(output_file.path());
253253

254+
// Clear environment variables to avoid leaking sensitive data
255+
command.env_clear();
256+
257+
// Preserve environment variables needed for font discovery
258+
if let Ok(path) = std::env::var("PATH") {
259+
command.env("PATH", path);
260+
}
261+
if let Ok(home) = std::env::var("HOME") {
262+
command.env("HOME", home);
263+
}
264+
254265
let output = command.output().await;
255266
let output = output.map_err(OgImageError::TypstNotFound)?;
256267

0 commit comments

Comments
 (0)