summaryrefslogtreecommitdiff
path: root/ext/mysqli
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-09-18 10:29:28 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-09-18 15:24:57 +0200
commit70cba36fc92c1e75c5b0f9ebd1f97a68c26c170a (patch)
treedc11b483f230b01ff61b7054f25dbfa3c89e9e29 /ext/mysqli
parent77f43e48ffa9b4083a26870ca2fce8757c273bd3 (diff)
downloadphp-git-70cba36fc92c1e75c5b0f9ebd1f97a68c26c170a.tar.gz
Support NO_BACKSLASH_ESCAPES with newer libmysqlclient
Requires the use of mysql_real_escape_string_quote().
Diffstat (limited to 'ext/mysqli')
-rw-r--r--ext/mysqli/mysqli_api.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c
index 0c17e1599e..7d8682253c 100644
--- a/ext/mysqli/mysqli_api.c
+++ b/ext/mysqli/mysqli_api.c
@@ -1954,6 +1954,11 @@ PHP_FUNCTION(mysqli_real_query)
}
/* }}} */
+#if defined(PDO_USE_MYSQLND) || MYSQL_VERSION_ID < 50707 || defined(MARIADB_BASE_VERSION)
+# define mysql_real_escape_string_quote(mysql, to, from, length, quote) \
+ mysql_real_escape_string(mysql, to, from, length)
+#endif
+
/* {{{ proto string mysqli_real_escape_string(object link, string escapestr)
Escapes special characters in a string for use in a SQL statement, taking into account the current charset of the connection */
PHP_FUNCTION(mysqli_real_escape_string) {
@@ -1969,7 +1974,7 @@ PHP_FUNCTION(mysqli_real_escape_string) {
MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
newstr = zend_string_alloc(2 * escapestr_len, 0);
- ZSTR_LEN(newstr) = mysql_real_escape_string(mysql->mysql, ZSTR_VAL(newstr), escapestr, escapestr_len);
+ ZSTR_LEN(newstr) = mysql_real_escape_string_quote(mysql->mysql, ZSTR_VAL(newstr), escapestr, escapestr_len, '\'');
newstr = zend_string_truncate(newstr, ZSTR_LEN(newstr), 0);
RETURN_NEW_STR(newstr);