Only encode text once

Html.ReplaceLineBreaks calls WebUtility.HtmlEncode internally, so the text gets encoded by this method.

As far as I know, WebUtility.HtmlEncode and HttpUtility.HtmlEncode produces the same result (unlike WebUtility.UrlEncode and HttpUtility.UrlEncode which produces different results; see https://edi.wang/post/2018/11/25/netcore-webutility-urlencode-httputility-urlencode), so it should be safe to omit HttpUtility.HtmlEncode here.
This commit is contained in:
Kenny Nielsen
2021-08-12 15:59:55 +02:00
committed by Sebastiaan Janssen
parent 7710409be8
commit e4a2fc2736

View File

@@ -4,7 +4,7 @@
@if (Model.editor.config.markup != null)
{
string markup = Model.editor.config.markup.ToString();
markup = markup.Replace("#value#", Html.ReplaceLineBreaks(HttpUtility.HtmlEncode((string)Model.value.ToString())).ToString());
markup = markup.Replace("#value#", Html.ReplaceLineBreaks((string)Model.value.ToString()).ToString());
if (Model.editor.config.style != null)
{