@@ -1463,9 +1463,9 @@ async function sshRun(
|
1463 | 1463 | }); |
1464 | 1464 | } |
1465 | 1465 | |
1466 | | -function renderRemoteSetup(params: { tdlibSha256?: string; tdlibUrl?: string }) { |
1467 | | -const tdlibSha256 = JSON.stringify(params.tdlibSha256 ?? ""); |
1468 | | -const tdlibUrl = JSON.stringify(params.tdlibUrl ?? ""); |
| 1466 | +export function renderRemoteSetup(params: { tdlibSha256?: string; tdlibUrl?: string }) { |
| 1467 | +const tdlibSha256 = shellQuote(params.tdlibSha256 ?? ""); |
| 1468 | +const tdlibUrl = shellQuote(params.tdlibUrl ?? ""); |
1469 | 1469 | return `#!/usr/bin/env bash |
1470 | 1470 | set -euo pipefail |
1471 | 1471 | root=${REMOTE_ROOT} |
@@ -1617,10 +1617,10 @@ sleep 6
|
1617 | 1617 | `; |
1618 | 1618 | } |
1619 | 1619 | |
1620 | | -function renderSelectDesktopChat(params: { chatTitle: string }) { |
| 1620 | +export function renderSelectDesktopChat(params: { chatTitle: string }) { |
1621 | 1621 | return `#!/usr/bin/env bash |
1622 | 1622 | set -euo pipefail |
1623 | | -chat_title=${JSON.stringify(params.chatTitle)} |
| 1623 | +chat_title=${shellQuote(params.chatTitle)} |
1624 | 1624 | export DISPLAY="\${DISPLAY:-:99}" |
1625 | 1625 | win="$(wmctrl -l | awk 'tolower($0) ~ /telegram/ {print $1; exit}')" |
1626 | 1626 | test -n "$win" |
@@ -1639,7 +1639,7 @@ sleep 1
|
1639 | 1639 | `; |
1640 | 1640 | } |
1641 | 1641 | |
1642 | | -function renderRemoteProbe(params: { |
| 1642 | +export function renderRemoteProbe(params: { |
1643 | 1643 | expect: string[]; |
1644 | 1644 | outputPath?: string; |
1645 | 1645 | sutUsername: string; |
@@ -1659,12 +1659,12 @@ function renderRemoteProbe(params: {
|
1659 | 1659 | for (const expected of params.expect) { |
1660 | 1660 | args.push("--expect", expected); |
1661 | 1661 | } |
1662 | | -const escapedArgs = args.map((arg) => JSON.stringify(arg)).join(" "); |
| 1662 | +const escapedArgs = args.map(shellQuote).join(" "); |
1663 | 1663 | return `#!/usr/bin/env bash |
1664 | 1664 | set -euo pipefail |
1665 | 1665 | root=${REMOTE_ROOT} |
1666 | 1666 | export TELEGRAM_USER_DRIVER_STATE_DIR="$root/user-driver" |
1667 | | -export TELEGRAM_USER_DRIVER_SUT_USERNAME=${JSON.stringify(params.sutUsername)} |
| 1667 | +export TELEGRAM_USER_DRIVER_SUT_USERNAME=${shellQuote(params.sutUsername)} |
1668 | 1668 | python3 "$root/user-driver.py" ${escapedArgs} |
1669 | 1669 | `; |
1670 | 1670 | } |
@@ -1926,7 +1926,7 @@ async function writeRemoteSessionScripts(params: {
|
1926 | 1926 | params.inspect, |
1927 | 1927 | `cat >${REMOTE_ROOT}/env.sh <<'EOF' |
1928 | 1928 | export TELEGRAM_USER_DRIVER_STATE_DIR=${REMOTE_ROOT}/user-driver |
1929 | | -export TELEGRAM_USER_DRIVER_SUT_USERNAME=${params.sutUsername} |
| 1929 | +export TELEGRAM_USER_DRIVER_SUT_USERNAME=${shellQuote(params.sutUsername)} |
1930 | 1930 | EOF |
1931 | 1931 | `, |
1932 | 1932 | ); |
@@ -1956,7 +1956,7 @@ async function stopRemoteRecording(root: string, inspect: CrabboxInspect, sessio
|
1956 | 1956 | root, |
1957 | 1957 | inspect, |
1958 | 1958 | `set -euo pipefail |
1959 | | -pid_file=${JSON.stringify(session.recorder.pidFile)} |
| 1959 | +pid_file=${shellQuote(session.recorder.pidFile)} |
1960 | 1960 | if [ -s "$pid_file" ]; then |
1961 | 1961 | pid="$(cat "$pid_file")" |
1962 | 1962 | kill -INT "$pid" >/dev/null 2>&1 || true |
|