]> BookStack Code Mirror - system-cli/blobdiff - src/Services/MySqlRunner.php
Added escaping for MySQL config options
[system-cli] / src / Services / MySqlRunner.php
index d83f446b98a41df9134a700427e8271e7da0363f..e1c4a0fbf3529c10aaf64551988ddd5842eeddbe 100644 (file)
@@ -32,7 +32,8 @@ class MySqlRunner
     protected function createOptionsFile(): string
     {
         $path = tempnam(sys_get_temp_dir(), 'bs-cli-mysql-opts');
-        $contents = "[client]\nuser={$this->user}\nhost={$this->host}\nport={$this->port}\npassword={$this->password}\nprotocol=TCP";
+        $password = str_replace('\\', '\\\\', $this->password);
+        $contents = "[client]\nuser='{$this->user}'\nhost='{$this->host}'\nport={$this->port}\npassword='{$password}'\nprotocol=TCP";
         file_put_contents($path, $contents);
         chmod($path, 0600);
         return $path;