From 875a895eaed1bbd8b53207c92c8227c21a629645 Mon Sep 17 00:00:00 2001 From: Kevin Jump Date: Tue, 16 Apr 2024 11:14:25 +0100 Subject: [PATCH] #612 - couple of extra checks so we never try to create an XCData section with a null value. --- uSync.Core/Serialization/Serializers/ContentSerializerBase.cs | 4 ++-- uSync.Core/Serialization/Serializers/DataTypeSerializer.cs | 2 +- uSync.Core/Serialization/Serializers/TemplateSerializer.cs | 2 +- uSync.Core/Serialization/Serializers/WebhookSerializer.cs | 2 +- uSync.Core/Tracking/Impliment/DataTypeTracker.cs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/uSync.Core/Serialization/Serializers/ContentSerializerBase.cs b/uSync.Core/Serialization/Serializers/ContentSerializerBase.cs index f7f69c61..97042ed8 100644 --- a/uSync.Core/Serialization/Serializers/ContentSerializerBase.cs +++ b/uSync.Core/Serialization/Serializers/ContentSerializerBase.cs @@ -665,8 +665,8 @@ protected string GetExportValue(object value, IPropertyType propertyType, string { return JsonConvert.SerializeObject(tokenValue, Formatting.Indented); } - logger.LogTrace("Export Value {PropertyEditorAlias} {exportValue}", propertyType.PropertyEditorAlias, exportValue); - return exportValue; + logger.LogTrace("Export Value {PropertyEditorAlias} [{exportValue}]", propertyType.PropertyEditorAlias, exportValue ?? string.Empty); + return exportValue ?? string.Empty; } protected object GetImportValue(string value, IPropertyType propertyType, string culture, string segment) diff --git a/uSync.Core/Serialization/Serializers/DataTypeSerializer.cs b/uSync.Core/Serialization/Serializers/DataTypeSerializer.cs index bd2f2393..bd6f4b2d 100644 --- a/uSync.Core/Serialization/Serializers/DataTypeSerializer.cs +++ b/uSync.Core/Serialization/Serializers/DataTypeSerializer.cs @@ -269,7 +269,7 @@ private XElement SerializeConfiguration(IDataType item) config = serializer.SerializeConfig(item.Configuration); } - return new XElement("Config", new XCData(config)); + return new XElement("Config", new XCData(config ?? string.Empty)); } return null; diff --git a/uSync.Core/Serialization/Serializers/TemplateSerializer.cs b/uSync.Core/Serialization/Serializers/TemplateSerializer.cs index 49fb840d..f337e496 100644 --- a/uSync.Core/Serialization/Serializers/TemplateSerializer.cs +++ b/uSync.Core/Serialization/Serializers/TemplateSerializer.cs @@ -285,7 +285,7 @@ protected override SyncAttempt SerializeCore(ITemplate item, SyncSeria private XElement SerializeContent(ITemplate item) { - return new XElement("Contents", new XCData(item.Content)); + return new XElement("Contents", new XCData(item.Content ?? string.Empty)); } private int CalculateLevel(ITemplate item) diff --git a/uSync.Core/Serialization/Serializers/WebhookSerializer.cs b/uSync.Core/Serialization/Serializers/WebhookSerializer.cs index 55c6174b..cdd87df1 100644 --- a/uSync.Core/Serialization/Serializers/WebhookSerializer.cs +++ b/uSync.Core/Serialization/Serializers/WebhookSerializer.cs @@ -250,7 +250,7 @@ private static XElement SerializeHeaders(IWebhook item) { headerNode.Add(new XElement("Header", new XAttribute("Key", headerItem.Key), - new XCData(headerItem.Value))); + new XCData(headerItem.Value ?? string.Empty))); } return headerNode; diff --git a/uSync.Core/Tracking/Impliment/DataTypeTracker.cs b/uSync.Core/Tracking/Impliment/DataTypeTracker.cs index 4f4c70c6..1a7c71e6 100644 --- a/uSync.Core/Tracking/Impliment/DataTypeTracker.cs +++ b/uSync.Core/Tracking/Impliment/DataTypeTracker.cs @@ -108,7 +108,7 @@ private ISyncConfigMerger GetConfigMerger(string editorAlias) => _configMergers?.GetConfigMerger(editorAlias) ?? null; private string SerializeConfig(object config) - => JsonConvert.SerializeObject(config, Formatting.Indented, _jsonSettings); + => JsonConvert.SerializeObject(config, Formatting.Indented, _jsonSettings) ?? string.Empty; }