From a928b4ea1fed50b01dcd9c44ed249b5d8c740e2c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Jun 2026 18:10:00 +0000 Subject: [PATCH 1/2] Initial plan From 61c53049955b134f884f01d2ce4a620509b24858 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Jun 2026 18:15:45 +0000 Subject: [PATCH 2/2] Fix JsonFormatter to preserve Unicode output Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com> --- .../Elsa.Common/Services/JsonFormatter.cs | 9 +++++++-- .../JsonFormatterTests.cs | 20 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 test/unit/Elsa.Common.UnitTests/JsonFormatterTests.cs diff --git a/src/modules/Elsa.Common/Services/JsonFormatter.cs b/src/modules/Elsa.Common/Services/JsonFormatter.cs index d543942c22..b8265a56a6 100644 --- a/src/modules/Elsa.Common/Services/JsonFormatter.cs +++ b/src/modules/Elsa.Common/Services/JsonFormatter.cs @@ -1,5 +1,7 @@ +using System.Text.Encodings.Web; using System.Text.Json; using System.Text.Json.Serialization; +using System.Text.Unicode; namespace Elsa.Common.Services; @@ -10,14 +12,17 @@ public class JsonFormatter : IFormatter public JsonFormatter() { - _options = new JsonSerializerOptions(); + _options = new JsonSerializerOptions + { + Encoder = JavaScriptEncoder.Create(UnicodeRanges.All) + }; _options.Converters.Add(new JsonStringEnumConverter()); } /// public ValueTask ToStringAsync(object value, CancellationToken cancellationToken = default) { - var json = JsonSerializer.Serialize(value); + var json = JsonSerializer.Serialize(value, _options); return ValueTask.FromResult(json); } diff --git a/test/unit/Elsa.Common.UnitTests/JsonFormatterTests.cs b/test/unit/Elsa.Common.UnitTests/JsonFormatterTests.cs new file mode 100644 index 0000000000..6844c7f835 --- /dev/null +++ b/test/unit/Elsa.Common.UnitTests/JsonFormatterTests.cs @@ -0,0 +1,20 @@ +using Elsa.Common.Services; + +namespace Elsa.Common.UnitTests; + +public class JsonFormatterTests +{ + [Fact] + public async Task ToStringAsync_DoesNotEscapeUnicodeCharacters() + { + var formatter = new JsonFormatter(); + var value = new { Name = "ÆØÅ" }; + + var json = await formatter.ToStringAsync(value); + + Assert.Contains("ÆØÅ", json); + Assert.DoesNotContain(@"\u00C6", json, StringComparison.OrdinalIgnoreCase); + Assert.DoesNotContain(@"\u00D8", json, StringComparison.OrdinalIgnoreCase); + Assert.DoesNotContain(@"\u00C5", json, StringComparison.OrdinalIgnoreCase); + } +}