Skip to content

Commit 87933e5

Browse files
committed
Proper quoting of strings in trace config (#1149).
1 parent 7b08f61 commit 87933e5

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/FirebirdSql.Data.FirebirdClient/Services/FbTraceConfiguration.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@
1515

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

18-
using System;
19-
using System.Collections.Generic;
2018
using System.Globalization;
21-
using System.Linq;
22-
using System.Text;
2319

2420
namespace FirebirdSql.Data.Services;
2521

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

3329
protected static string WriteString(string s)
3430
{
35-
return string.Format("'{0}'", s);
31+
s = s
32+
.Replace("{", "{{")
33+
.Replace("}", "}}")
34+
.Replace(@"\", @"\\")
35+
.Replace("\"", "\\\"");
36+
return string.Format("\"{0}\"", s);
3637
}
3738

3839
protected static string WriteNumber(int i)
@@ -42,6 +43,6 @@ protected static string WriteNumber(int i)
4243

4344
protected static string WriteRegEx(string re)
4445
{
45-
return WriteString(re.Replace(@"\", @"\\").Replace("'", @"\'"));
46+
return WriteString(re);
4647
}
4748
}

0 commit comments

Comments
 (0)