MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:rburnett Date:July 22 2008 7:21pm
Subject:Connector/NET commit: r1351 - in branches/5.2: . MySql.Data/Provider/Source MySql.Data/Provider/Source/Types
View as plain text  
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
+
+        /// <summary>
+        /// Escapes the string.
+        /// </summary>
+        /// <param name="value">The string to escape</param>
+        /// <returns>The string with all quotes escaped.</returns>
+		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)

Thread
Connector/NET commit: r1351 - in branches/5.2: . MySql.Data/Provider/Source MySql.Data/Provider/Source/Typesrburnett22 Jul