Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a83baad

Browse filesBrowse files
committed
Use mysql_real_escape_string_quote() if exists.
1 parent 05fbc50 commit a83baad
Copy full SHA for a83baad

File tree

Expand file treeCollapse file tree

1 file changed

+11
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-2
lines changed

‎_mysql.c

Copy file name to clipboardExpand all lines: _mysql.c
+11-2Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,10 +1063,15 @@ _mysql_escape_string(
10631063

10641064
if (self && PyModule_Check((PyObject*)self))
10651065
self = NULL;
1066-
if (self && self->open)
1066+
if (self && self->open) {
1067+
#if MYSQL_VERSION_ID >= 50706
1068+
len = mysql_real_escape_string_quote(&(self->connection), out, in, size, '\'');
1069+
#else
10671070
len = mysql_real_escape_string(&(self->connection), out, in, size);
1068-
else
1071+
#endif
1072+
} else {
10691073
len = mysql_escape_string(out, in, size);
1074+
}
10701075
if (_PyBytes_Resize(&str, len) < 0) return NULL;
10711076
return (str);
10721077
}
@@ -1117,7 +1122,11 @@ _mysql_string_literal(
11171122
out = PyBytes_AS_STRING(str);
11181123
check_server_init(NULL);
11191124
if (self && self->open) {
1125+
#if MYSQL_VERSION_ID >= 50706
1126+
len = mysql_real_escape_string_quote(&(self->connection), out+1, in, size, '\'');
1127+
#else
11201128
len = mysql_real_escape_string(&(self->connection), out+1, in, size);
1129+
#endif
11211130
} else {
11221131
len = mysql_escape_string(out+1, in, size);
11231132
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.