fix: sanitize foreground output path segments (#1238)