From 5eeb8d7df6c67ce9c0424f3ddf4976770ef8e984 Mon Sep 17 00:00:00 2001 From: Shannon Date: Wed, 26 Mar 2014 11:00:32 +1100 Subject: [PATCH] Fixes: U4-4520 Issue: MultipleTextStringValueConverter returns an empty string array due to mismatched XML value format --- .../MultipleTextStringValueConverter.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Umbraco.Core/PropertyEditors/ValueConverters/MultipleTextStringValueConverter.cs b/src/Umbraco.Core/PropertyEditors/ValueConverters/MultipleTextStringValueConverter.cs index 17ecbaeed1..6725257888 100644 --- a/src/Umbraco.Core/PropertyEditors/ValueConverters/MultipleTextStringValueConverter.cs +++ b/src/Umbraco.Core/PropertyEditors/ValueConverters/MultipleTextStringValueConverter.cs @@ -31,6 +31,10 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters var sourceString = source.ToString(); if (string.IsNullOrWhiteSpace(sourceString)) return Enumerable.Empty(); + //SD: I have no idea why this logic is here, I'm pretty sure we've never saved the multiple txt string + // as xml in the database, it's always been new line delimited. Will ask Stephen about this. + // In the meantime, we'll do this xml check, see if it parses and if not just continue with + // splitting by newline var values = new List(); var pos = sourceString.IndexOf("", StringComparison.Ordinal); while (pos >= 0) @@ -41,6 +45,13 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters values.Add(value); pos = sourceString.IndexOf("", pos, StringComparison.Ordinal); } + + // Fall back on normal behaviour + if (values.Any() == false) + { + return sourceString.Split(Environment.NewLine.ToCharArray()); + } + return values.ToArray(); }