diff --git a/build/versions.props b/build/versions.props
index b3aaa42ad7..03d5d76370 100644
--- a/build/versions.props
+++ b/build/versions.props
@@ -55,7 +55,7 @@
7.0.0
7.0.0
7.0.1
- 7.0.0
+ 7.1.0
7.0.0
7.0.0
7.0.0
diff --git a/src/HealthChecks.UI.Client/UIResponseWriter.cs b/src/HealthChecks.UI.Client/UIResponseWriter.cs
index 1abb69c09f..803163bc64 100644
--- a/src/HealthChecks.UI.Client/UIResponseWriter.cs
+++ b/src/HealthChecks.UI.Client/UIResponseWriter.cs
@@ -1,5 +1,7 @@
+using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Json.Serialization;
+using System.Text.Unicode;
using HealthChecks.UI.Core;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Diagnostics.HealthChecks;
@@ -55,6 +57,7 @@ private static JsonSerializerOptions CreateJsonOptions()
{
AllowTrailingCommas = true,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
+ Encoder = JavaScriptEncoder.Create(UnicodeRanges.All),
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull
};
diff --git a/test/HealthChecks.UI.Client.Tests/UIResponseWriterTests.cs b/test/HealthChecks.UI.Client.Tests/UIResponseWriterTests.cs
index f399db53dc..c7ffd540ef 100644
--- a/test/HealthChecks.UI.Client.Tests/UIResponseWriterTests.cs
+++ b/test/HealthChecks.UI.Client.Tests/UIResponseWriterTests.cs
@@ -32,6 +32,30 @@ public async Task should_response_with_obfuscated_exception_when_exception_messa
healthReport.ShouldNotBeNull().Entries[healthReportKey].Exception.ShouldBe(exceptionMessage);
}
+ [Theory]
+ [InlineData("你好")]
+ [InlineData("жарко")]
+ [InlineData("ąężćś")]
+ public async Task should_not_encode_unicode_characters(string healthReportKey)
+ {
+ var httpContext = new DefaultHttpContext();
+ httpContext.Response.Body = new MemoryStream();
+ var entries = new Dictionary
+ {
+ { healthReportKey, new HealthReportEntry(HealthStatus.Healthy, null, TimeSpan.FromSeconds(1), null, null) }
+ };
+ var report = new HealthReport(entries, TimeSpan.FromSeconds(1));
+
+ await UIResponseWriter.WriteHealthCheckUIResponse(httpContext, report).ConfigureAwait(false);
+
+ httpContext.Response.Body.Seek(0, SeekOrigin.Begin);
+
+ var responseStreamReader = new StreamReader(httpContext.Response.Body);
+ var responseAsText = await responseStreamReader.ReadToEndAsync().ConfigureAwait(false);
+
+ responseAsText.ShouldContain(healthReportKey);
+ }
+
private static JsonSerializerOptions CreateJsonOptions()
{
var options = new JsonSerializerOptions