Commit 0a1f6ac7 0a1f6ac7e8567490012820d6c4b62c006909bb53 by Sergey Poznyakoff

(sql_escape_string): Escape backslashes.

1 parent b9315681
...@@ -72,10 +72,11 @@ sql_escape_string (const char *ustr) ...@@ -72,10 +72,11 @@ sql_escape_string (const char *ustr)
72 char *str, *q; 72 char *str, *q;
73 const unsigned char *p; 73 const unsigned char *p;
74 size_t len = strlen (ustr); 74 size_t len = strlen (ustr);
75 #define ESCAPABLE_CHAR "\\'\""
75 76
76 for (p = (const unsigned char *) ustr; *p; p++) 77 for (p = (const unsigned char *) ustr; *p; p++)
77 { 78 {
78 if (strchr ("'\"", *p)) 79 if (strchr (ESCAPABLE_CHAR, *p))
79 len++; 80 len++;
80 } 81 }
81 82
...@@ -85,7 +86,7 @@ sql_escape_string (const char *ustr) ...@@ -85,7 +86,7 @@ sql_escape_string (const char *ustr)
85 86
86 for (p = (const unsigned char *) ustr, q = str; *p; p++) 87 for (p = (const unsigned char *) ustr, q = str; *p; p++)
87 { 88 {
88 if (strchr ("'\"", *p)) 89 if (strchr (ESCAPABLE_CHAR, *p))
89 *q++ = '\\'; 90 *q++ = '\\';
90 *q++ = *p; 91 *q++ = *p;
91 } 92 }
......