[DevFilePreview]JSON: Don't escape HTML-sensitive characters (#23054)

This commit is contained in:
Davide Giacometti 2023-01-09 12:08:15 +01:00 committed by GitHub
parent 473e5dbf75
commit ad18765ebc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Text.Encodings.Web;
using System.Text.Json;
namespace Microsoft.PowerToys.PreviewHandler.Monaco.Formatters
@ -21,7 +22,11 @@ namespace Microsoft.PowerToys.PreviewHandler.Monaco.Formatters
using (var jDocument = JsonDocument.Parse(value, new JsonDocumentOptions { CommentHandling = JsonCommentHandling.Skip }))
{
return JsonSerializer.Serialize(jDocument, new JsonSerializerOptions { WriteIndented = true });
return JsonSerializer.Serialize(jDocument, new JsonSerializerOptions
{
WriteIndented = true,
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
});
}
}
}