Skip to content

Commit f273be9

Browse files
swissspidyCopilot
andauthored
Update src/DB_Users_Command.php
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 381a520 commit f273be9

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

‎src/DB_Users_Command.php‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,14 @@ public function create( $args, $assoc_args ) {
101101
/**
102102
* Escapes a string for use in a SQL query.
103103
*
104-
* Follows MySQL's documented string literal escaping rules.
105-
* See https://dev.mysql.com/doc/refman/en/string-literals.html
104+
* Uses SQL-standard single-quote escaping (`'` => `''`) so the generated
105+
* literal remains valid even when MySQL is running with
106+
* `NO_BACKSLASH_ESCAPES`.
106107
*
107108
* @param string $value String to escape.
108109
* @return string Escaped string, wrapped in single quotes.
109110
*/
110111
private function esc_sql_string( $value ) {
111-
// Escape special characters according to MySQL string literal rules.
112-
$value = str_replace(
113-
[ '\\', "\x00", "\n", "\r", "'", '"', "\x1a" ],
114-
[ '\\\\', "\\0", "\\n", "\\r", "\\'", '\\"', '\\Z' ],
115-
$value
116-
);
117-
return "'" . $value . "'";
112+
return "'" . str_replace( "'", "''", $value ) . "'";
118113
}
119114
}

0 commit comments

Comments
 (0)