Merge branch 'v8/8.14' into v8/8.15

This commit is contained in:
Sebastiaan Janssen
2021-08-23 14:52:05 +02:00

View File

@@ -5,6 +5,7 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Umbraco.Core;
using Umbraco.Core.Composing;
using Umbraco.Core.Logging;
using Umbraco.Core.Models.Blocks;
using Umbraco.Core.PropertyEditors;
@@ -17,6 +18,17 @@ namespace Umbraco.Web.Compose
{
private ComplexPropertyEditorContentEventHandler _handler;
private readonly BlockListEditorDataConverter _converter = new BlockListEditorDataConverter();
private readonly ILogger _logger;
[Obsolete("Use the ctor injecting dependencies.")]
public BlockEditorComponent() : this(Current.Logger)
{
}
public BlockEditorComponent(ILogger logger)
{
_logger = logger;
}
public void Initialize()
{
@@ -116,8 +128,23 @@ namespace Umbraco.Web.Compose
// this gets a little ugly because there could be some other complex editor that contains another block editor
// and since we would have no idea how to parse that, all we can do is try JSON Path to find another block editor
// of our type
var json = JToken.Parse(asString);
if (ProcessJToken(json, createGuid, out var result))
JToken json = null;
try
{
json = JToken.Parse(asString);
}
catch (Exception e)
{
// See issue https://github.com/umbraco/Umbraco-CMS/issues/10879
// We are detecting JSON data by seeing if a string is surrounded by [] or {}
// If people enter text like [PLACEHOLDER] JToken parsing fails, it's safe to ignore though
// Logging this just in case in the future we find values that are not safe to ignore
_logger.Warn<BlockEditorComponent>(
"The property {PropertyAlias} on content type {ContentTypeKey} has a value of: {BlockItemValue} - this was recognized as JSON but could not be parsed",
data.Key, propertyAliasToBlockItemData.Key, asString);
}
if (json != null && ProcessJToken(json, createGuid, out var result))
{
// need to re-save this back to the RawPropertyValues
data.RawPropertyValues[propertyAliasToBlockItemData.Key] = result;