fix(host-deployer): escape back quote (#19357)

This commit is contained in:
wanyaoqi
2024-01-27 08:10:25 +08:00
committed by GitHub
parent 70bcc94c86
commit e46f1babad
+3 -2
View File
@@ -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)