Skip to content

Commit affbb9c

Browse files
committed
Escape single quote and backslash when writing GUIDs as byte arrays.
1 parent e05bc5b commit affbb9c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/MySqlConnector/MySqlClient/MySqlParameter.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,12 @@ internal void AppendSqlString(BinaryWriter writer, StatementPreparerOptions opti
161161
if ((options & StatementPreparerOptions.OldGuids) != 0)
162162
{
163163
writer.WriteUtf8("_binary'");
164-
writer.Write(guidValue.ToByteArray());
164+
foreach (var by in guidValue.ToByteArray())
165+
{
166+
if (by == 0x27 || by == 0x5C)
167+
writer.Write((byte) 0x5C);
168+
writer.Write(by);
169+
}
165170
writer.Write((byte) '\'');
166171
}
167172
else

0 commit comments

Comments
 (0)