Skip to content

Commit

Permalink
improve escaping double quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Jan 10, 2025
1 parent 6a99ef5 commit 3ab6e6a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion MyApp.ServiceInterface/AiServerServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,10 @@ public static string SanitizeBody(string? body)
}
catch (Exception)
{
json = json.Replace("\"", "\\\"");
// Escape quotes, revert escaping JSON properties and try again
json = json.Replace("\"", "\\\"")
.Replace("\\\"reason\\\"", "\"reason\"")
.Replace("\\\"score\\\"", "\"score\"");
obj = (Dictionary<string, object>)JSON.parse(json);
}
var reason = obj.TryGetValue("reason", out var oReason)
Expand Down

0 comments on commit 3ab6e6a

Please sign in to comment.