From 807df434f63ec3341fe909592bd2c47c4cff98e4 Mon Sep 17 00:00:00 2001 From: yawka Date: Thu, 7 Nov 2013 18:39:02 +0200 Subject: [PATCH] Add validation for regular expression property --- src/Umbraco.Core/Models/PropertyType.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Core/Models/PropertyType.cs b/src/Umbraco.Core/Models/PropertyType.cs index 3b4915862a..cfeb9e832d 100644 --- a/src/Umbraco.Core/Models/PropertyType.cs +++ b/src/Umbraco.Core/Models/PropertyType.cs @@ -361,8 +361,16 @@ namespace Umbraco.Core.Models //Check against Regular Expression for Legacy DataTypes - Validation exists and value is not null: if(string.IsNullOrEmpty(ValidationRegExp) == false && (value != null && string.IsNullOrEmpty(value.ToString()) == false)) { - var regexPattern = new Regex(ValidationRegExp); - return regexPattern.IsMatch(value.ToString()); + try + { + var regexPattern = new Regex(ValidationRegExp); + return regexPattern.IsMatch(value.ToString()); + } + catch + { + throw new Exception(string .Format("Invalid validation expression on property {0}",this.Alias)); + } + } //TODO Add PropertyEditor validation when its relevant to introduce