From 43c50324d802b815eadddabc0d772eddad595b13 Mon Sep 17 00:00:00 2001 From: Sanqui Date: Mon, 14 Dec 2020 20:57:48 +0100 Subject: [PATCH] [JSON] Don't escape Unicode characters when possible (#453) While UnsafeRelaxedJsonEscaping sounds scary, there is no risk here since the JSON data is saved directly into a file. See #450 --- .../Exporting/Writers/JsonMessageWriter.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DiscordChatExporter.Domain/Exporting/Writers/JsonMessageWriter.cs b/DiscordChatExporter.Domain/Exporting/Writers/JsonMessageWriter.cs index 2b92732..fa26700 100644 --- a/DiscordChatExporter.Domain/Exporting/Writers/JsonMessageWriter.cs +++ b/DiscordChatExporter.Domain/Exporting/Writers/JsonMessageWriter.cs @@ -1,6 +1,7 @@ using System.IO; using System.Text.Json; using System.Threading.Tasks; +using System.Text.Encodings.Web; using DiscordChatExporter.Domain.Discord.Models; using DiscordChatExporter.Domain.Exporting.Writers.MarkdownVisitors; using DiscordChatExporter.Domain.Internal.Extensions; @@ -19,6 +20,7 @@ namespace DiscordChatExporter.Domain.Exporting.Writers { _writer = new Utf8JsonWriter(stream, new JsonWriterOptions { + Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping, Indented = true }); }