Skip to content

Commit

Permalink
Escape single quote and backslash when writing GUIDs as byte arrays.
Browse files Browse the repository at this point in the history
  • Loading branch information
adampoit committed May 25, 2017
1 parent e05bc5b commit affbb9c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/MySqlConnector/MySqlClient/MySqlParameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,12 @@ internal void AppendSqlString(BinaryWriter writer, StatementPreparerOptions opti
if ((options & StatementPreparerOptions.OldGuids) != 0)
{
writer.WriteUtf8("_binary'");
writer.Write(guidValue.ToByteArray());
foreach (var by in guidValue.ToByteArray())
{
if (by == 0x27 || by == 0x5C)
writer.Write((byte) 0x5C);
writer.Write(by);
}
writer.Write((byte) '\'');
}
else
Expand Down

0 comments on commit affbb9c

Please sign in to comment.