Check if value is null or whitespace before reading grid configuration

This commit is contained in:
Bjarne Fyrstenborg
2019-10-08 18:55:44 +02:00
parent e7196d5edf
commit 646bfb02f2

View File

@@ -78,20 +78,20 @@ namespace Umbraco.Web.PropertyEditors
if (editorValue.Value == null)
return null;
var config = editorValue.DataTypeConfiguration as GridConfiguration;
var mediaParent = config?.MediaParentId;
var mediaParentId = mediaParent == null ? Guid.Empty : mediaParent.Guid;
// editorValue.Value is a JSON string of the grid
var rawJson = editorValue.Value.ToString();
if (rawJson.IsNullOrWhiteSpace())
return null;
var config = editorValue.DataTypeConfiguration as GridConfiguration;
var mediaParent = config?.MediaParentId;
var mediaParentId = mediaParent == null ? Guid.Empty : mediaParent.Guid;
var grid = DeserializeGridValue(rawJson, out var rtes);
var userId = _umbracoContextAccessor.UmbracoContext?.Security.CurrentUser.Id ?? Constants.Security.SuperUserId;
//process the rte values
// Process the rte values
foreach (var rte in rtes)
{
// Parse the HTML