From 31bf3d55ba7578254fc1b1a4921baf999a00dd7b Mon Sep 17 00:00:00 2001 From: SC-IDO Date: Fri, 12 Aug 2022 18:13:20 +0300 Subject: [PATCH] Take real value of setting HtmlEncodedFieldTypes #547118 --- .../zzz/Sitecore.Support.547118.config | 10 +++++-- .../GetTextFieldValue.cs | 27 +++++++------------ 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/Sitecore.Support.547118/App_Config/Include/zzz/Sitecore.Support.547118.config b/src/Sitecore.Support.547118/App_Config/Include/zzz/Sitecore.Support.547118.config index 63baac1..aa77830 100644 --- a/src/Sitecore.Support.547118/App_Config/Include/zzz/Sitecore.Support.547118.config +++ b/src/Sitecore.Support.547118/App_Config/Include/zzz/Sitecore.Support.547118.config @@ -1,4 +1,10 @@ - - + + + + + + + \ No newline at end of file diff --git a/src/Sitecore.Support.547118/GetTextFieldValue.cs b/src/Sitecore.Support.547118/GetTextFieldValue.cs index 3464cb9..0649423 100644 --- a/src/Sitecore.Support.547118/GetTextFieldValue.cs +++ b/src/Sitecore.Support.547118/GetTextFieldValue.cs @@ -1,30 +1,23 @@ -using Sitecore.Configuration; +using Sitecore.Abstractions; +using Sitecore.Configuration.KnownSettings; using Sitecore.Diagnostics; using Sitecore.Pipelines.RenderField; -using System; +using System.Linq; +using System.Reflection; using System.Web; namespace Sitecore.Support.Pipelines.RenderField { - public class GetTextFieldValue + public class GetTextFieldValue: Sitecore.Pipelines.RenderField.GetTextFieldValue { - public void Process([NotNull] RenderFieldArgs args) - { - Assert.ArgumentNotNull(args, "args"); - - this.EncodeFieldValue(args); - - var typeKey = args.FieldTypeKey; - if (typeKey.Equals("text", StringComparison.InvariantCulture) || typeKey.Equals("single-line text", StringComparison.InvariantCulture)) - { - args.WebEditParameters.Add("prevent-line-break", "true"); - } - } + private static readonly BindingFlags _bflags = BindingFlags.NonPublic | BindingFlags.Static; + private static readonly PropertyInfo SettingsInstance_Prop = typeof(Sitecore.Configuration.Settings).GetProperty("SettingsInstance", _bflags); + private static readonly BaseSettings SettingsInstance = SettingsInstance_Prop.GetValue(null) as Sitecore.Abstractions.BaseSettings; - protected virtual void EncodeFieldValue([NotNull] RenderFieldArgs args) + protected override void EncodeFieldValue([NotNull] RenderFieldArgs args) { Assert.ArgumentNotNull(args, "args"); - if (Settings.Rendering.HtmlEncodedFieldTypes.Contains(args.FieldTypeKey)) + if (SettingsInstance.Rendering().HtmlEncodedFieldTypes.Contains(args.FieldTypeKey)) { args.Result.FirstPart = HttpUtility.HtmlEncode(args.Result.FirstPart); }