From b2e9fb1534449c5c754bbee4c7c3e16e04646867 Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Wed, 6 Jul 2016 11:00:34 +0200 Subject: [PATCH] Need to UrlDecode the parts[1] part so that we can find and properly delete properties with ampersands --- .../umbraco/create/stylesheetPropertyTasks.cs | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/create/stylesheetPropertyTasks.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/create/stylesheetPropertyTasks.cs index d1d607a7d8..fe589a6dbb 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/create/stylesheetPropertyTasks.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/create/stylesheetPropertyTasks.cs @@ -1,30 +1,22 @@ using System; -using System.Data; using System.Linq; using System.Web; -using System.Web.Security; -using System.Windows.Forms; using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Web.UI; using umbraco.BusinessLogic; -using umbraco.DataLayer; -using umbraco.BasePages; -using Umbraco.Core.IO; -using umbraco.cms.businesslogic.member; namespace umbraco { public class stylesheetPropertyTasks : LegacyDialogTask { - public override bool PerformSave() { var stylesheetName = AdditionalValues["nodeId"].ToString(); - - var s = Umbraco.Core.ApplicationContext.Current.Services.FileService.GetStylesheetByName(stylesheetName.EnsureEndsWith(".css")); + + var s = ApplicationContext.Current.Services.FileService.GetStylesheetByName(stylesheetName.EnsureEndsWith(".css")); s.AddProperty(new StylesheetProperty(Alias, "." + Alias.ToSafeAlias(), "")); - Umbraco.Core.ApplicationContext.Current.Services.FileService.SaveStylesheet(s); + ApplicationContext.Current.Services.FileService.SaveStylesheet(s); _returnUrl = string.Format("settings/stylesheet/property/EditStyleSheetProperty.aspx?id={0}&prop={1}", HttpUtility.UrlEncode(s.Path), HttpUtility.UrlEncode(Alias)); return true; @@ -34,15 +26,16 @@ namespace umbraco { var parts = Alias.Split('_'); - var stylesheet = Umbraco.Core.ApplicationContext.Current.Services.FileService.GetStylesheetByName(parts[0].EnsureEndsWith(".css")); + var stylesheet = ApplicationContext.Current.Services.FileService.GetStylesheetByName(parts[0].EnsureEndsWith(".css")); if (stylesheet == null) throw new InvalidOperationException("No stylesheet found by name: " + parts[0]); - var prop = stylesheet.Properties.FirstOrDefault(x => x.Name == parts[1]); - if (prop == null) throw new InvalidOperationException("No stylesheet property found by name: " + parts[1]); + var property = HttpUtility.UrlDecode(parts[1]); + var prop = stylesheet.Properties.FirstOrDefault(x => x.Name == property); + if (prop == null) throw new InvalidOperationException("No stylesheet property found by name: " + property); stylesheet.RemoveProperty(prop.Name); - Umbraco.Core.ApplicationContext.Current.Services.FileService.SaveStylesheet(stylesheet); + ApplicationContext.Current.Services.FileService.SaveStylesheet(stylesheet); return true; }