From 87933e5e9edb79dcab32f410431c407cd8219b10 Mon Sep 17 00:00:00 2001 From: Jiri Cincura Date: Sun, 10 Dec 2023 15:27:45 +0100 Subject: [PATCH] Proper quoting of strings in trace config (#1149). --- .../Services/FbTraceConfiguration.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/FirebirdSql.Data.FirebirdClient/Services/FbTraceConfiguration.cs b/src/FirebirdSql.Data.FirebirdClient/Services/FbTraceConfiguration.cs index 10573f1cc..2b6f9ffc7 100644 --- a/src/FirebirdSql.Data.FirebirdClient/Services/FbTraceConfiguration.cs +++ b/src/FirebirdSql.Data.FirebirdClient/Services/FbTraceConfiguration.cs @@ -15,11 +15,7 @@ //$Authors = Jiri Cincura (jiri@cincura.net) -using System; -using System.Collections.Generic; using System.Globalization; -using System.Linq; -using System.Text; namespace FirebirdSql.Data.Services; @@ -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) @@ -42,6 +43,6 @@ protected static string WriteNumber(int i) protected static string WriteRegEx(string re) { - return WriteString(re.Replace(@"\", @"\\").Replace("'", @"\'")); + return WriteString(re); } }