mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-05-05 15:31:27 +00:00
reslove comment
This commit is contained in:
parent
305d35e680
commit
fe14e1db85
6 changed files with 239 additions and 80 deletions
|
|
@ -12,6 +12,7 @@ import {
|
|||
getShellConfiguration,
|
||||
ShellExecutionService,
|
||||
flatMapTextParts,
|
||||
checkArgumentSafety,
|
||||
} from '@qwen-code/qwen-code-core';
|
||||
import type { AnyToolInvocation } from '@qwen-code/qwen-code-core';
|
||||
|
||||
|
|
@ -101,6 +102,16 @@ export class ShellProcessor implements IPromptProcessor {
|
|||
const { shell } = getShellConfiguration();
|
||||
const userArgsEscaped = escapeShellArg(userArgsRaw, shell);
|
||||
|
||||
// Check safety of the value that will be used for $ARGUMENTS (after removing outer quotes)
|
||||
let userArgsForArgumentsPlaceholder = userArgsRaw.replace(
|
||||
/^'([\s\S]*?)'$/,
|
||||
'$1',
|
||||
);
|
||||
const argumentSafety = checkArgumentSafety(userArgsForArgumentsPlaceholder);
|
||||
if (!argumentSafety.isSafe) {
|
||||
userArgsForArgumentsPlaceholder = userArgsEscaped;
|
||||
}
|
||||
|
||||
const resolvedInjections: ResolvedShellInjection[] = injections.map(
|
||||
(injection) => {
|
||||
const command = injection.content;
|
||||
|
|
@ -111,10 +122,7 @@ export class ShellProcessor implements IPromptProcessor {
|
|||
|
||||
const resolvedCommand = command
|
||||
.replaceAll(SHORTHAND_ARGS_PLACEHOLDER, userArgsEscaped) // Replace {{args}}
|
||||
.replaceAll(
|
||||
'$ARGUMENTS',
|
||||
userArgsRaw.replace(/^'([\s\S]*?)'$/, '$1'),
|
||||
);
|
||||
.replaceAll('$ARGUMENTS', userArgsForArgumentsPlaceholder);
|
||||
return { ...injection, resolvedCommand };
|
||||
},
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue