Skip to content

Commit

Permalink
Take real value of setting HtmlEncodedFieldTypes #547118
Browse files Browse the repository at this point in the history
  • Loading branch information
SC-IDO committed Aug 12, 2022
1 parent c0b0c99 commit 31bf3d5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
<sitecore role:require="Standalone OR ContentManagement OR ContentDelivery">
</sitecore>
<sitecore role:require="Standalone OR ContentManagement OR ContentDelivery">
<pipelines>
<renderField>
<processor type="Sitecore.Support.Pipelines.RenderField.GetTextFieldValue, Sitecore.Support.547118"
patch:instead="processor[@type='Sitecore.Pipelines.RenderField.GetTextFieldValue, Sitecore.Kernel']" />
</renderField>
</pipelines>
</sitecore>
</configuration>
27 changes: 10 additions & 17 deletions src/Sitecore.Support.547118/GetTextFieldValue.cs
Original file line number Diff line number Diff line change
@@ -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);
}
Expand Down

0 comments on commit 31bf3d5

Please sign in to comment.