X-Git-Url: http://source.bookstackapp.com/system-cli/blobdiff_plain/86c680259923ce3675366585842890ca09004e10..refs/heads/22-mysql-cred-escaping:/src/Services/MySqlRunner.php diff --git a/src/Services/MySqlRunner.php b/src/Services/MySqlRunner.php index d83f446..e1c4a0f 100644 --- a/src/Services/MySqlRunner.php +++ b/src/Services/MySqlRunner.php @@ -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;