Skip to content

Commit

Permalink
#612 - couple of extra checks so we never try to create an XCData sec…
Browse files Browse the repository at this point in the history
…tion with a null value.
  • Loading branch information
KevinJump committed Apr 16, 2024
1 parent 54ffb02 commit 875a895
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions uSync.Core/Serialization/Serializers/ContentSerializerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion uSync.Core/Serialization/Serializers/DataTypeSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion uSync.Core/Serialization/Serializers/TemplateSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ protected override SyncAttempt<XElement> 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)
Expand Down
2 changes: 1 addition & 1 deletion uSync.Core/Serialization/Serializers/WebhookSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion uSync.Core/Tracking/Impliment/DataTypeTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;


}
Expand Down

0 comments on commit 875a895

Please sign in to comment.