Skip to content

Commit

Permalink
0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
NickFox007 authored Aug 5, 2024
1 parent d2019e0 commit b27eaff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
24 changes: 20 additions & 4 deletions Bases/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> 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;
}
Expand All @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion CAnyBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ public static IAnyBase Base(string name)
}

public static int Version()
{ return 7; }
{ return 8; }
}
}

0 comments on commit b27eaff

Please sign in to comment.