mirror of
https://github.com/siteboon/claudecodeui.git
synced 2025-12-11 10:49:37 +00:00
fix prompt injection bug
This commit is contained in:
@@ -25,15 +25,6 @@ async function spawnClaude(command, options = {}, ws) {
|
|||||||
// Build Claude CLI command - start with print/resume flags first
|
// Build Claude CLI command - start with print/resume flags first
|
||||||
const args = [];
|
const args = [];
|
||||||
|
|
||||||
// Add print flag with command if we have a command
|
|
||||||
if (command && command.trim()) {
|
|
||||||
|
|
||||||
// Separate arguments for better cross-platform compatibility
|
|
||||||
// This prevents issues with spaces and quotes on Windows
|
|
||||||
args.push('--print');
|
|
||||||
args.push(command);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use cwd (actual project directory) instead of projectPath (Claude's metadata directory)
|
// Use cwd (actual project directory) instead of projectPath (Claude's metadata directory)
|
||||||
const workingDir = cwd || process.cwd();
|
const workingDir = cwd || process.cwd();
|
||||||
|
|
||||||
@@ -226,6 +217,17 @@ async function spawnClaude(command, options = {}, ws) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add print flag with command if we have a command
|
||||||
|
if (command && command.trim()) {
|
||||||
|
|
||||||
|
// Separate arguments for better cross-platform compatibility
|
||||||
|
// This prevents issues with spaces and quotes on Windows
|
||||||
|
args.push('--print');
|
||||||
|
// Use `--` so user input is always treated as text, not options
|
||||||
|
args.push('--');
|
||||||
|
args.push(command);
|
||||||
|
}
|
||||||
|
|
||||||
console.log('Spawning Claude CLI:', 'claude', args.map(arg => {
|
console.log('Spawning Claude CLI:', 'claude', args.map(arg => {
|
||||||
const cleanArg = arg.replace(/\n/g, '\\n').replace(/\r/g, '\\r');
|
const cleanArg = arg.replace(/\n/g, '\\n').replace(/\r/g, '\\r');
|
||||||
return cleanArg.includes(' ') ? `"${cleanArg}"` : cleanArg;
|
return cleanArg.includes(' ') ? `"${cleanArg}"` : cleanArg;
|
||||||
|
|||||||
Reference in New Issue
Block a user