diff --git a/Bases/Common.cs b/Bases/Common.cs index e1b5592..b705573 100644 --- a/Bases/Common.cs +++ b/Bases/Common.cs @@ -14,15 +14,30 @@ namespace AnyBaseLib.Bases { internal static class Common - { + { //private static string logpath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),"queries.txt"); + private static string ReplaceFirst(this string text, string search, string replace) + { + int pos = text.IndexOf(search); + if (pos < 0) + { + return text; + } + return text.Substring(0, pos) + replace + text.Substring(pos + search.Length); + } + public static string _PrepareClear(string q, List args) { var new_q = q; if(args != null) foreach (var arg in args.ToList()) { - var regex = new Regex(Regex.Escape("{ARG}")); - var new_q2 = regex.Replace(new_q, _PrepareArg(arg), 1); + //var regex = new Regex(Regex.Escape("{ARG}")); + + //var new_q2 = regex.Replace(new_q, _PrepareArg(arg), 1); + + var new_q2 = ReplaceFirst(new_q, "{ARG}", _PrepareArg(arg)); + + if (new_q2 == new_q) throw new Exception("Mailformed query [Too many args in params]"); new_q = new_q2; } @@ -36,7 +51,8 @@ public static string _PrepareArg(string arg) var new_arg = arg; - string[] escapes = ["'", "\"", "`", "%", "-", "_"]; + //string[] escapes = ["'", "\"", "`", "%", "-", "_"]; + string[] escapes = ["'", "\"", "`", "%"]; foreach (var escape in escapes) { diff --git a/CAnyBase.cs b/CAnyBase.cs index bec80b3..0383633 100644 --- a/CAnyBase.cs +++ b/CAnyBase.cs @@ -21,6 +21,6 @@ public static IAnyBase Base(string name) } public static int Version() - { return 7; } + { return 8; } } }