Skip to content

Commit

Permalink
Proper quoting of strings in trace config (#1149).
Browse files Browse the repository at this point in the history
  • Loading branch information
cincuranet committed Dec 10, 2023
1 parent 7b08f61 commit 87933e5
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@

//$Authors = Jiri Cincura ([email protected])

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;

namespace FirebirdSql.Data.Services;

Expand All @@ -32,7 +28,12 @@ protected static string WriteBoolValue(bool b)

protected static string WriteString(string s)
{
return string.Format("'{0}'", s);
s = s
.Replace("{", "{{")
.Replace("}", "}}")
.Replace(@"\", @"\\")
.Replace("\"", "\\\"");
return string.Format("\"{0}\"", s);
}

protected static string WriteNumber(int i)
Expand All @@ -42,6 +43,6 @@ protected static string WriteNumber(int i)

protected static string WriteRegEx(string re)
{
return WriteString(re.Replace(@"\", @"\\").Replace("'", @"\'"));
return WriteString(re);
}
}

0 comments on commit 87933e5

Please sign in to comment.