fix(cli): Support special characters in sandbox profile path (#2038)

Co-authored-by: Jacob Richman <jacob314@gmail.com>
Co-authored-by: Allen Hutchison <adh@google.com>
This commit is contained in:
George Smith
2025-08-22 22:36:57 +01:00
committed by GitHub
parent 75822d3506
commit 33d49291ec

View File

@@ -9,6 +9,7 @@ import os from 'node:os';
import path from 'node:path'; import path from 'node:path';
import fs from 'node:fs'; import fs from 'node:fs';
import { readFile } from 'node:fs/promises'; import { readFile } from 'node:fs/promises';
import { fileURLToPath } from 'node:url';
import { quote, parse } from 'shell-quote'; import { quote, parse } from 'shell-quote';
import { import {
USER_SETTINGS_DIR, USER_SETTINGS_DIR,
@@ -200,9 +201,12 @@ export async function start_sandbox(
console.error('ERROR: cannot BUILD_SANDBOX when using macOS Seatbelt'); console.error('ERROR: cannot BUILD_SANDBOX when using macOS Seatbelt');
process.exit(1); process.exit(1);
} }
const profile = (process.env['SEATBELT_PROFILE'] ??= 'permissive-open'); const profile = (process.env['SEATBELT_PROFILE'] ??= 'permissive-open');
let profileFile = new URL(`sandbox-macos-${profile}.sb`, import.meta.url) let profileFile = fileURLToPath(
.pathname; new URL(`sandbox-macos-${profile}.sb`, import.meta.url),
);
// if profile name is not recognized, then look for file under project settings directory // if profile name is not recognized, then look for file under project settings directory
if (!BUILTIN_SEATBELT_PROFILES.includes(profile)) { if (!BUILTIN_SEATBELT_PROFILES.includes(profile)) {
profileFile = path.join( profileFile = path.join(