From dd210ab801e9f7c41c9b2b21db62fdc5df37d1c1 Mon Sep 17 00:00:00 2001 From: Nathan Heskew Date: Tue, 5 Apr 2011 13:10:23 -0700 Subject: [PATCH 1/2] Ensuring the layer change when editing a widget overrides the persisted container ID from the CommonPart work item: 17650 --HG-- branch : 1.x --- .../Modules/Orchard.Widgets/Controllers/AdminController.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Orchard.Web/Modules/Orchard.Widgets/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.Widgets/Controllers/AdminController.cs index 9603e14fa..33082b2e8 100644 --- a/src/Orchard.Web/Modules/Orchard.Widgets/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Widgets/Controllers/AdminController.cs @@ -344,8 +344,9 @@ namespace Orchard.Widgets.Controllers { if (widgetPart == null) return HttpNotFound(); - widgetPart.LayerPart = _widgetsService.GetLayer(layerId); var model = Services.ContentManager.UpdateEditor(widgetPart, this); + // override the CommonPart's persisting of the current container + widgetPart.LayerPart = _widgetsService.GetLayer(layerId); if (!ModelState.IsValid) { Services.TransactionManager.Cancel(); // Casting to avoid invalid (under medium trust) reflection over the protected View method and force a static invocation. From 48975f4ca446d9c65c71c518e90551e741c2841b Mon Sep 17 00:00:00 2001 From: Nathan Heskew Date: Tue, 5 Apr 2011 13:32:43 -0700 Subject: [PATCH 2/2] Forbidding the use of backslashes in slugs. work item: 16593 --HG-- branch : 1.x --- .../Routable/Services/RoutableServiceTests.cs | 4 ++-- src/Orchard.Web/Core/Routable/Drivers/RoutePartDriver.cs | 2 +- src/Orchard.Web/Core/Routable/Services/RoutableService.cs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Orchard.Core.Tests/Routable/Services/RoutableServiceTests.cs b/src/Orchard.Core.Tests/Routable/Services/RoutableServiceTests.cs index 733afe807..084ec8512 100644 --- a/src/Orchard.Core.Tests/Routable/Services/RoutableServiceTests.cs +++ b/src/Orchard.Core.Tests/Routable/Services/RoutableServiceTests.cs @@ -72,7 +72,7 @@ namespace Orchard.Core.Tests.Routable.Services { var thing = contentManager.Create("thing", t => { t.As().Record = new RoutePartRecord(); - t.Title = "Please do not use any of the following characters in your permalink: \":\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\", \"\"\", \"<\", \">\""; + t.Title = "Please do not use any of the following characters in your permalink: \":\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\", \"\"\", \"<\", \">\", \"\\\""; }); _routableService.FillSlugFromTitle(thing.As()); @@ -120,7 +120,7 @@ namespace Orchard.Core.Tests.Routable.Services { public void InvalidCharacterShouldBeRefusedInSlugs() { Assert.That(_routableService.IsSlugValid("aaaa-_aaaa"), Is.True); - foreach (var c in @":?#[]@!$&'()*+,;= ") { + foreach (var c in @":?#[]@!$&'()*+,;= \") { Assert.That(_routableService.IsSlugValid("a" + c + "b"), Is.False); } } diff --git a/src/Orchard.Web/Core/Routable/Drivers/RoutePartDriver.cs b/src/Orchard.Web/Core/Routable/Drivers/RoutePartDriver.cs index dd035565e..e940dd7fc 100644 --- a/src/Orchard.Web/Core/Routable/Drivers/RoutePartDriver.cs +++ b/src/Orchard.Web/Core/Routable/Drivers/RoutePartDriver.cs @@ -89,7 +89,7 @@ namespace Orchard.Core.Routable.Drivers { if ( slug.StartsWith(".") || slug.EndsWith(".") ) updater.AddModelError("Routable.Slug", T("The \".\" can't be used at either end of the permalink.")); else - updater.AddModelError("Routable.Slug", T("Please do not use any of the following characters in your permalink: \":\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\", \", \"<\", \">\". No spaces are allowed (please use dashes or underscores instead).")); + updater.AddModelError("Routable.Slug", T("Please do not use any of the following characters in your permalink: \":\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\", \", \"<\", \">\", \"\\\". No spaces are allowed (please use dashes or underscores instead).")); } return Editor(part, shapeHelper); diff --git a/src/Orchard.Web/Core/Routable/Services/RoutableService.cs b/src/Orchard.Web/Core/Routable/Services/RoutableService.cs index c78782dcb..eecb2c11d 100644 --- a/src/Orchard.Web/Core/Routable/Services/RoutableService.cs +++ b/src/Orchard.Web/Core/Routable/Services/RoutableService.cs @@ -57,7 +57,7 @@ namespace Orchard.Core.Routable.Services { } if (!slugContext.Adjusted) { - var disallowed = new Regex(@"[/:?#\[\]@!$&'()*+,;=\s\""\<\>]+"); + var disallowed = new Regex(@"[/:?#\[\]@!$&'()*+,;=\s\""\<\>\\]+"); slugContext.Slug = disallowed.Replace(slugContext.Slug, "-").Trim('-'); @@ -108,7 +108,7 @@ namespace Orchard.Core.Routable.Services { } public bool IsSlugValid(string slug) { - return String.IsNullOrWhiteSpace(slug) || Regex.IsMatch(slug, @"^[^:?#\[\]@!$&'()*+,;=\s\""\<\>]+$") && !(slug.StartsWith(".") || slug.EndsWith(".")); + return String.IsNullOrWhiteSpace(slug) || Regex.IsMatch(slug, @"^[^:?#\[\]@!$&'()*+,;=\s\""\<\>\\]+$") && !(slug.StartsWith(".") || slug.EndsWith(".")); } public bool ProcessSlug(IRoutableAspect part) {