From: Date: July 22 2008 9:21pm
Subject: Connector/NET commit: r1351 - in branches/5.2: . MySql.Data/Provider/Source MySql.Data/Provider/Source/Types
List-Archive: http://lists.mysql.com/commits/50225
X-Bug: 36205
Message-Id: <200807221921.m6MJL5t2016638@bk-internal.mysql.com>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Modified:
branches/5.2/CHANGES
branches/5.2/MySql.Data/Provider/Source/MySqlHelper.cs
branches/5.2/MySql.Data/Provider/Source/Types/MySqlString.cs
Log:
- moved string escaping routine from the MySqlString class to the MySqlHelper class
and made it public and static. (bug #36205)
Modified: branches/5.2/CHANGES
===================================================================
--- branches/5.2/CHANGES 2008-07-22 19:20:16 UTC (rev 1350)
+++ branches/5.2/CHANGES 2008-07-22 19:21:05 UTC (rev 1351)
@@ -21,6 +21,8 @@
'reading from stream failed'. (bug #38119)
- fixed problem where adding a non-existent user to a role would not auto-create the
user record (bug #38243)
+- moved string escaping routine from the MySqlString class to the MySqlHelper class
+ and made it public and static. (bug #36205)
Version 5.2.2 -
- Fixed profile provider that would throw an exception if you were updating
Modified: branches/5.2/MySql.Data/Provider/Source/MySqlHelper.cs
===================================================================
--- branches/5.2/MySql.Data/Provider/Source/MySqlHelper.cs 2008-07-22 19:20:16 UTC (rev 1350)
+++ branches/5.2/MySql.Data/Provider/Source/MySqlHelper.cs 2008-07-22 19:21:05 UTC (rev 1351)
@@ -359,5 +359,26 @@
}
#endregion
- }
+
+ #region Utility methods
+
+ ///
+ /// Escapes the string.
+ ///
+ /// The string to escape
+ /// The string with all quotes escaped.
+ public static string EscapeString(string value)
+ {
+ value = value.Replace("\\", "\\\\");
+ value = value.Replace("\'", "\\\'");
+ value = value.Replace("\"", "\\\"");
+ value = value.Replace("`", "\\`");
+ value = value.Replace("´", "\\´");
+ value = value.Replace("’", "\\’");
+ value = value.Replace("‘", "\\‘");
+ return value;
+ }
+
+ #endregion
+ }
}
Modified: branches/5.2/MySql.Data/Provider/Source/Types/MySqlString.cs
===================================================================
--- branches/5.2/MySql.Data/Provider/Source/Types/MySqlString.cs 2008-07-22 19:20:16 UTC (rev 1350)
+++ branches/5.2/MySql.Data/Provider/Source/Types/MySqlString.cs 2008-07-22 19:21:05 UTC (rev 1351)
@@ -82,18 +82,8 @@
get { return type == MySqlDbType.Set ? "SET" : type == MySqlDbType.Enum ? "ENUM" : "VARCHAR"; }
}
- private string EscapeString(string s)
- {
- s = s.Replace("\\", "\\\\");
- s = s.Replace("\'", "\\\'");
- s = s.Replace("\"", "\\\"");
- s = s.Replace("`", "\\`");
- s = s.Replace("´", "\\´");
- s = s.Replace("’", "\\’");
- s = s.Replace("‘", "\\‘");
- return s;
- }
+
void IMySqlValue.WriteValue(MySqlStream stream, bool binary, object val, int length)
{
string v = val.ToString();
@@ -106,7 +96,7 @@
if (binary)
stream.WriteLenString(v);
else
- stream.WriteStringNoNull("'" + EscapeString(v) + "'");
+ stream.WriteStringNoNull("'" + MySqlHelper.EscapeString(v) + "'");
}
IMySqlValue IMySqlValue.ReadValue(MySqlStream stream, long length, bool nullVal)