From e46f1babad0ea5f1c61d49742e49caa7550e9ab3 Mon Sep 17 00:00:00 2001 From: wanyaoqi <18528551+wanyaoqi@users.noreply.github.com> Date: Sat, 27 Jan 2024 08:10:25 +0800 Subject: [PATCH] fix(host-deployer): escape back quote (#19357) --- pkg/hostman/diskutils/qemu_kvm/driver.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/hostman/diskutils/qemu_kvm/driver.go b/pkg/hostman/diskutils/qemu_kvm/driver.go index c4452fd184..d8f8d10a58 100644 --- a/pkg/hostman/diskutils/qemu_kvm/driver.go +++ b/pkg/hostman/diskutils/qemu_kvm/driver.go @@ -382,10 +382,11 @@ func (d *QemuKvmDriver) sshRun(cmd string) ([]string, error) { } func (d *QemuKvmDriver) sshFilePutContent(params interface{}, filePath string) error { - jcontent := jsonutils.Marshal(params) + jcontent := jsonutils.Marshal(params).String() + jcontent = strings.ReplaceAll(jcontent, "`", "\\`") cmd := fmt.Sprintf(`cat << EOF > %s %s -EOF`, filePath, jcontent.String()) +EOF`, filePath, jcontent) out, err := d.sshRun(cmd) if err != nil { return errors.Wrapf(err, "sshFilePutContent %s", out)