From 7bafff2dfba74bc813fdf90d9b61ec7df90b4a00 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Mon, 15 Nov 2010 17:31:31 -0800 Subject: [PATCH 1/2] Updating disallowed chars in routes and titles http://orchard.codeplex.com/workitem/16367 --HG-- branch : dev --- src/Orchard.Web/Core/Routable/Drivers/RoutePartDriver.cs | 2 +- src/Orchard.Web/Core/Routable/Services/RoutableService.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Orchard.Web/Core/Routable/Drivers/RoutePartDriver.cs b/src/Orchard.Web/Core/Routable/Drivers/RoutePartDriver.cs index cb72a284c..976894f8a 100644 --- a/src/Orchard.Web/Core/Routable/Drivers/RoutePartDriver.cs +++ b/src/Orchard.Web/Core/Routable/Drivers/RoutePartDriver.cs @@ -82,7 +82,7 @@ namespace Orchard.Core.Routable.Drivers { if ( slug.StartsWith(".") || slug.EndsWith(".") ) updater.AddModelError("Routable.Slug", T("The \".\" can't be used around routes.")); else - updater.AddModelError("Routable.Slug", T("Please do not use any of the following characters in your slugs: \":\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\". 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 slugs: \":\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\", \", \"<\", \">\". No spaces are allowed (please use dashes or underscores instead).")); } if (part.ContentItem.Id != 0 && model.PromoteToHomePage && _routableHomePageProvider != null) diff --git a/src/Orchard.Web/Core/Routable/Services/RoutableService.cs b/src/Orchard.Web/Core/Routable/Services/RoutableService.cs index aa6f776d9..2ddea2f21 100644 --- a/src/Orchard.Web/Core/Routable/Services/RoutableService.cs +++ b/src/Orchard.Web/Core/Routable/Services/RoutableService.cs @@ -32,7 +32,7 @@ namespace Orchard.Core.Routable.Services { return; var slug = model.Title; - var dissallowed = new Regex(@"[/:?#\[\]@!$&'()*+,;=\s]+"); + var dissallowed = new Regex(@"[/:?#\[\]@!$&'()*+,;=\s\""\<\>]+"); slug = dissallowed.Replace(slug, "-"); slug = slug.Trim('-'); @@ -79,7 +79,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) { From f750c1172eea0d24511c095d533ebf8d65245a26 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Mon, 15 Nov 2010 18:03:14 -0800 Subject: [PATCH 2/2] Validating Title and Slug lengths http://orchard.codeplex.com/workitem/16707 --HG-- branch : dev --- src/Orchard.Web/Core/Routable/Drivers/RoutePartDriver.cs | 1 - src/Orchard.Web/Core/Routable/Migrations.cs | 2 +- src/Orchard.Web/Core/Routable/Models/RoutePart.cs | 1 + src/Orchard.Web/Core/Routable/Models/RoutePartRecord.cs | 1 + .../Core/Routable/ViewModels/RoutableEditorViewModel.cs | 2 ++ 5 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Orchard.Web/Core/Routable/Drivers/RoutePartDriver.cs b/src/Orchard.Web/Core/Routable/Drivers/RoutePartDriver.cs index 976894f8a..d3b6b8b8c 100644 --- a/src/Orchard.Web/Core/Routable/Drivers/RoutePartDriver.cs +++ b/src/Orchard.Web/Core/Routable/Drivers/RoutePartDriver.cs @@ -9,7 +9,6 @@ using Orchard.Core.Routable.Services; using Orchard.Core.Routable.ViewModels; using Orchard.Localization; using Orchard.Services; -using Orchard.UI.Notify; namespace Orchard.Core.Routable.Drivers { public class RoutePartDriver : ContentPartDriver { diff --git a/src/Orchard.Web/Core/Routable/Migrations.cs b/src/Orchard.Web/Core/Routable/Migrations.cs index 4105ca610..22e6f5c2d 100644 --- a/src/Orchard.Web/Core/Routable/Migrations.cs +++ b/src/Orchard.Web/Core/Routable/Migrations.cs @@ -10,7 +10,7 @@ namespace Orchard.Core.Routable { table => table .ContentPartVersionRecord() .Column("Title", column => column.WithLength(1024)) - .Column("Slug") + .Column("Slug", column => column.WithLength(1024)) .Column("Path", column => column.WithLength(2048)) ); diff --git a/src/Orchard.Web/Core/Routable/Models/RoutePart.cs b/src/Orchard.Web/Core/Routable/Models/RoutePart.cs index 8896ff02b..284b0ed97 100644 --- a/src/Orchard.Web/Core/Routable/Models/RoutePart.cs +++ b/src/Orchard.Web/Core/Routable/Models/RoutePart.cs @@ -3,6 +3,7 @@ using Orchard.ContentManagement.Aspects; namespace Orchard.Core.Routable.Models { public class RoutePart : ContentPart, IRoutableAspect { + public string Title { get { return Record.Title; } set { Record.Title = value; } diff --git a/src/Orchard.Web/Core/Routable/Models/RoutePartRecord.cs b/src/Orchard.Web/Core/Routable/Models/RoutePartRecord.cs index b4680d63a..1097d8885 100644 --- a/src/Orchard.Web/Core/Routable/Models/RoutePartRecord.cs +++ b/src/Orchard.Web/Core/Routable/Models/RoutePartRecord.cs @@ -6,6 +6,7 @@ namespace Orchard.Core.Routable.Models { [StringLength(1024)] public virtual string Title { get; set; } + [StringLength(1024)] public virtual string Slug { get; set; } [StringLength(2048)] diff --git a/src/Orchard.Web/Core/Routable/ViewModels/RoutableEditorViewModel.cs b/src/Orchard.Web/Core/Routable/ViewModels/RoutableEditorViewModel.cs index ec251e4ce..4bdefc198 100644 --- a/src/Orchard.Web/Core/Routable/ViewModels/RoutableEditorViewModel.cs +++ b/src/Orchard.Web/Core/Routable/ViewModels/RoutableEditorViewModel.cs @@ -8,7 +8,9 @@ namespace Orchard.Core.Routable.ViewModels { public string ContentType { get; set; } [Required] + [StringLength(1024)] public string Title { get; set; } + [StringLength(1024)] public string Slug { get; set; } public int? ContainerId { get; set; } public bool PromoteToHomePage { get; set; }