escapeString() can get a null value.

This commit is contained in:
Markus Birth 2022-02-14 21:57:57 +01:00
parent ff2131f9e3
commit 09f47fc2d0
Signed by: mbirth
GPG Key ID: A9928D7A098C3A9A
8 changed files with 8 additions and 8 deletions

View File

@ -46,7 +46,7 @@ abstract class DbAbstract
/**
* Returns an escaped string, so that it can be safely included in a SQL string encapsulated within quotes, without allowing SQL injection.
*/
public function escapeString(string $string): string
public function escapeString($string): string
{
return $string;
}

View File

@ -200,7 +200,7 @@ class MysqliDatabase extends DbAbstract
/**
* Returns an escaped string, so that it can be safely included in a SQL string encapsulated within quotes, without allowing SQL injection.
*/
public function escapeString(string $string): string
public function escapeString($string): string
{
return mysqli_escape_string($this->db_conn, $string);
}

View File

@ -84,7 +84,7 @@ class PdoPostgresDatabase extends DbAbstract
/**
* Returns an escaped string, so that it can be safely included in a SQL string encapsulated within quotes, without allowing SQL injection.
*/
public function escapeString(string $string): string
public function escapeString($string): string
{
return substr($this->db_conn->quote($string), 1, -1);
}

View File

@ -120,7 +120,7 @@ class PdoSqliteDatabase extends DbAbstract
/**
* Returns an escaped string, so that it can be safely included in a SQL string encapsulated within quotes, without allowing SQL injection.
*/
public function escapeString(string $string): string
public function escapeString($string): string
{
return substr($this->db_conn->quote($string), 1, -1);
}

View File

@ -89,7 +89,7 @@ class PostgresDatabase extends DbAbstract
/**
* Returns an escaped string, so that it can be safely included in a SQL string encapsulated within quotes, without allowing SQL injection.
*/
public function escapeString(string $string): string
public function escapeString($string): string
{
return pg_escape_string($string);
}

View File

@ -322,7 +322,7 @@ class SqlRelayDatabase extends DbAbstract
/**
* Returns an escaped string, so that it can be safely included in a SQL string encapsulated within quotes, without allowing SQL injection.
*/
public function escapeString(string $string): string
public function escapeString($string): string
{
static $search = array("\x00", '%', "'", '\"');
static $replace = array('%00', '%25', "''", '\\\"');

View File

@ -60,7 +60,7 @@ class Sqlite3Database extends DbAbstract
/**
* Returns an escaped string, so that it can be safely included in a SQL string encapsulated within quotes, without allowing SQL injection.
*/
public function escapeString(string $string): string
public function escapeString($string): string
{
static $search = array("\x00", '%', "'", '\"');
static $replace = array('%00', '%25', "''", '\\\"');

View File

@ -64,7 +64,7 @@ class SqliteDatabase extends DbAbstract
/**
* Returns an escaped string, so that it can be safely included in a SQL string encapsulated within quotes, without allowing SQL injection.
*/
public function escapeString(string $string): string
public function escapeString($string): string
{
static $search = array("\x00", '%', "'", '\"');
static $replace = array('%00', '%25', "''", '\\\"');