From 3d66c201c2100be22a606432242fdf633bfe6db7 Mon Sep 17 00:00:00 2001 From: Shannon Date: Thu, 31 Oct 2019 14:08:38 +1100 Subject: [PATCH] Adds safety check of Udi.TryParse --- src/Umbraco.Web/PropertyEditors/ContentPickerPropertyEditor.cs | 3 ++- src/Umbraco.Web/PropertyEditors/MediaPickerPropertyEditor.cs | 3 ++- .../PropertyEditors/MultiNodeTreePickerPropertyEditor.cs | 3 ++- src/Umbraco.Web/PropertyEditors/MultiUrlPickerValueEditor.cs | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web/PropertyEditors/ContentPickerPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/ContentPickerPropertyEditor.cs index c09b3b6930..683f1a05c3 100644 --- a/src/Umbraco.Web/PropertyEditors/ContentPickerPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/ContentPickerPropertyEditor.cs @@ -41,7 +41,8 @@ namespace Umbraco.Web.PropertyEditors if (string.IsNullOrEmpty(asString)) yield break; - yield return new UmbracoEntityReference(Udi.Parse(asString)); + if (Udi.TryParse(asString, out var udi)) + yield return new UmbracoEntityReference(udi); } } } diff --git a/src/Umbraco.Web/PropertyEditors/MediaPickerPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/MediaPickerPropertyEditor.cs index be1a9b2691..ece210b9d1 100644 --- a/src/Umbraco.Web/PropertyEditors/MediaPickerPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/MediaPickerPropertyEditor.cs @@ -45,7 +45,8 @@ namespace Umbraco.Web.PropertyEditors if (string.IsNullOrEmpty(asString)) yield break; - yield return new UmbracoEntityReference(Udi.Parse(asString)); + if (Udi.TryParse(asString, out var udi)) + yield return new UmbracoEntityReference(udi); } } } diff --git a/src/Umbraco.Web/PropertyEditors/MultiNodeTreePickerPropertyEditor.cs b/src/Umbraco.Web/PropertyEditors/MultiNodeTreePickerPropertyEditor.cs index 020ad38c75..1da665a622 100644 --- a/src/Umbraco.Web/PropertyEditors/MultiNodeTreePickerPropertyEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/MultiNodeTreePickerPropertyEditor.cs @@ -37,7 +37,8 @@ namespace Umbraco.Web.PropertyEditors var udiPaths = asString.Split(','); foreach (var udiPath in udiPaths) { - yield return new UmbracoEntityReference(Udi.Parse(udiPath)); + if (Udi.TryParse(udiPath, out var udi)) + yield return new UmbracoEntityReference(udi); } } diff --git a/src/Umbraco.Web/PropertyEditors/MultiUrlPickerValueEditor.cs b/src/Umbraco.Web/PropertyEditors/MultiUrlPickerValueEditor.cs index 98f41c50b9..9c42fe6cbe 100644 --- a/src/Umbraco.Web/PropertyEditors/MultiUrlPickerValueEditor.cs +++ b/src/Umbraco.Web/PropertyEditors/MultiUrlPickerValueEditor.cs @@ -181,7 +181,7 @@ namespace Umbraco.Web.PropertyEditors if (string.IsNullOrEmpty(asString)) yield break; - var links = JsonConvert.DeserializeObject>(asString); + var links = JsonConvert.DeserializeObject>(asString); foreach (var link in links) { if (link.Udi != null) // Links can be absolute links without a Udi