















@@ -146,7 +146,7 @@ export const PINNED_REMOTE_PATH_MUTATION_SCRIPT = [
146146" ;;",
147147"esac",
148148].join("\n");
149-const ENSURE_REMOTE_REAL_DIRECTORY_SCRIPT = [
149+export const ENSURE_OPEN_SHELL_REMOTE_REAL_DIRECTORY_SCRIPT = [
150150"set -e",
151151'target="$1"',
152152'root="${2:-$1}"',
@@ -157,24 +157,24 @@ const ENSURE_REMOTE_REAL_DIRECTORY_SCRIPT = [
157157'[ -n "$target" ] || target="/"',
158158'[ -n "$root" ] || root="/"',
159159'case "$target/" in "$root"/*|"$root/") ;; *) echo "remote directory must stay under root: $target" >&2; exit 1 ;; esac',
160-'old_ifs="$IFS"',
161-'IFS="/"',
162-"set -- ${target#/} ${root#/}",
163-'IFS="$old_ifs"',
164-"for part do",
165-' [ -n "$part" ] || continue',
166-' case "$part" in "."|"..") echo "unsafe remote directory component: $part" >&2; exit 1 ;; esac',
160+'for path_to_check in "$target" "$root"; do',
161+' relative="${path_to_check#/}"',
162+' while [ -n "$relative" ]; do',
163+' part="${relative%%/*}"',
164+' if [ "$part" = "$relative" ]; then relative=""; else relative="${relative#*/}"; fi',
165+' [ -n "$part" ] || continue',
166+' case "$part" in "."|"..") echo "unsafe remote directory component: $part" >&2; exit 1 ;; esac',
167+" done",
167168"done",
168169'if [ -L "$root" ]; then echo "unsafe remote root symlink: $root" >&2; exit 1; fi',
169170'mkdir -p -- "$root"',
170171'canonical_root="$(cd "$root" && pwd -P)"',
171172'relative="${target#"$root"}"',
172173'relative="${relative#/}"',
173174'current="$canonical_root"',
174-'IFS="/"',
175-"set -- $relative",
176-'IFS="$old_ifs"',
177-"for part do",
175+'while [ -n "$relative" ]; do',
176+' part="${relative%%/*}"',
177+' if [ "$part" = "$relative" ]; then relative=""; else relative="${relative#*/}"; fi',
178178' [ -n "$part" ] || continue',
179179' if [ "$current" = "/" ]; then next="/$part"; else next="$current/$part"; fi',
180180' if [ -L "$next" ]; then echo "unsafe remote directory symlink: $next" >&2; exit 1; fi',
@@ -678,7 +678,7 @@ class OpenShellSandboxBackendImpl {
678678this.params.remoteWorkspaceDir,
679679);
680680await this.runRemoteShellScriptInternal({
681-script: `${ENSURE_REMOTE_REAL_DIRECTORY_SCRIPT}\nfind "$1" -mindepth 1 -maxdepth 1 -exec rm -rf -- {} +`,
681+script: `${ENSURE_OPEN_SHELL_REMOTE_REAL_DIRECTORY_SCRIPT}\nfind "$1" -mindepth 1 -maxdepth 1 -exec rm -rf -- {} +`,
682682args: [remoteSkillsWorkspaceDir, this.params.remoteWorkspaceDir],
683683});
684684const stats = await fs.lstat(this.params.createParams.skillsWorkspaceDir).catch(() => null);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。