diff --git a/AzurePackage.proj b/AzurePackage.proj index 1f23f7413..22cc98ba7 100644 --- a/AzurePackage.proj +++ b/AzurePackage.proj @@ -84,7 +84,7 @@ - + diff --git a/src/Orchard.Azure/Orchard.Azure.Web/startup/ConfigureIIS.cmd b/src/Orchard.Azure/Orchard.Azure.Web/startup/ConfigureIIS.cmd index 9bb55e560..4b38bef3c 100644 --- a/src/Orchard.Azure/Orchard.Azure.Web/startup/ConfigureIIS.cmd +++ b/src/Orchard.Azure/Orchard.Azure.Web/startup/ConfigureIIS.cmd @@ -1,5 +1,5 @@ REM Check if this task is running on the compute emulator, if not then sets the Idle Timeout to zero -IF "%ComputeEmulatorRunning%" == "true" ( +IF "%ComputeEmulatorRunning%" == "false" ( %windir%\system32\inetsrv\appcmd set config -section:applicationPools -applicationPoolDefaults.processModel.idleTimeout:00:00:00 ) \ No newline at end of file diff --git a/src/Orchard.Tests/Data/RepositoryTests.cs b/src/Orchard.Tests/Data/RepositoryTests.cs index 921a5f291..4b6ec34db 100644 --- a/src/Orchard.Tests/Data/RepositoryTests.cs +++ b/src/Orchard.Tests/Data/RepositoryTests.cs @@ -190,5 +190,17 @@ namespace Orchard.Tests.Data { Assert.That(one.Name, Is.EqualTo("one")); Assert.That(one.Timespan.Value.Millisecond, Is.EqualTo(489)); } + + + [Test] + public void RepositoryFetchTakesExistsPredicate() { + CreateThreeFoos(); + + var array = new[] { "one", "two" }; + + var result = _fooRepos.Fetch(f => array.Contains(f.Name)).ToList(); + + Assert.That(result.Count(), Is.EqualTo(2)); + } } } \ No newline at end of file diff --git a/src/Orchard.Web/Config/Sample.HostComponents.config b/src/Orchard.Web/Config/Sample.HostComponents.config index 1ece073bc..c19f40239 100644 --- a/src/Orchard.Web/Config/Sample.HostComponents.config +++ b/src/Orchard.Web/Config/Sample.HostComponents.config @@ -1,7 +1,7 @@  - + diff --git a/src/Orchard.Web/Core/Common/Module.txt b/src/Orchard.Web/Core/Common/Module.txt index eb92063b3..d8fb46e57 100644 --- a/src/Orchard.Web/Core/Common/Module.txt +++ b/src/Orchard.Web/Core/Common/Module.txt @@ -2,8 +2,8 @@ AntiForgery: enabled Author: The Orchard Team Website: http://orchardproject.net -Version: 1.5.1 -OrchardVersion: 1.5.1 +Version: 1.6 +OrchardVersion: 1.6 Description: The common module introduces content parts that are going to be used by most content types (common, body, identity). FeatureDescription: Core content parts. Dependencies: Settings diff --git a/src/Orchard.Web/Core/Containers/Module.txt b/src/Orchard.Web/Core/Containers/Module.txt index 466860152..ea75fada6 100644 --- a/src/Orchard.Web/Core/Containers/Module.txt +++ b/src/Orchard.Web/Core/Containers/Module.txt @@ -2,8 +2,8 @@ AntiForgery: enabled Author: The Orchard Team Website: http://orchardproject.net -Version: 1.5.1 -OrchardVersion: 1.5.1 +Version: 1.6 +OrchardVersion: 1.6 Description: The containers module introduces container and containable behaviors for content items. FeatureDescription: Container and containable parts to enable parent-child relationships between content items. Dependencies: Contents, Feeds diff --git a/src/Orchard.Web/Core/Contents/Module.txt b/src/Orchard.Web/Core/Contents/Module.txt index 733e34177..77730626d 100644 --- a/src/Orchard.Web/Core/Contents/Module.txt +++ b/src/Orchard.Web/Core/Contents/Module.txt @@ -2,8 +2,8 @@ AntiForgery: enabled Author: The Orchard Team Website: http://orchardproject.net -Version: 1.5.1 -OrchardVersion: 1.5.1 +Version: 1.6 +OrchardVersion: 1.6 Description: The contents module enables the creation of custom content types. Features: Contents diff --git a/src/Orchard.Web/Core/Dashboard/Module.txt b/src/Orchard.Web/Core/Dashboard/Module.txt index 06aba75a6..e9b411f0b 100644 --- a/src/Orchard.Web/Core/Dashboard/Module.txt +++ b/src/Orchard.Web/Core/Dashboard/Module.txt @@ -2,8 +2,8 @@ AntiForgery: enabled Author: The Orchard Team Website: http://orchardproject.net -Version: 1.5.1 -OrchardVersion: 1.5.1 +Version: 1.6 +OrchardVersion: 1.6 Description: The dashboard module is providing the dashboard screen of the admininstration UI of the application. FeatureDescription: Standard admin dashboard. Category: Core diff --git a/src/Orchard.Web/Core/Feeds/Module.txt b/src/Orchard.Web/Core/Feeds/Module.txt index 5a7fb3c2e..78200efd6 100644 --- a/src/Orchard.Web/Core/Feeds/Module.txt +++ b/src/Orchard.Web/Core/Feeds/Module.txt @@ -2,8 +2,8 @@ AntiForgery: enabled Author: The Orchard Team Website: http://orchardproject.net -Version: 1.5.1 -OrchardVersion: 1.5.1 +Version: 1.6 +OrchardVersion: 1.6 Description: The Feeds module is providing RSS feeds to content items. FeatureDescription: RSS feeds for content items. Category: Syndication diff --git a/src/Orchard.Web/Core/Navigation/Handlers/ContentMenuItemPartHandler.cs b/src/Orchard.Web/Core/Navigation/Handlers/ContentMenuItemPartHandler.cs index c0a833a11..6bfd7e71a 100644 --- a/src/Orchard.Web/Core/Navigation/Handlers/ContentMenuItemPartHandler.cs +++ b/src/Orchard.Web/Core/Navigation/Handlers/ContentMenuItemPartHandler.cs @@ -27,6 +27,12 @@ namespace Orchard.Core.Navigation.Handlers { var contentMenuItemPart = context.ContentItem.As(); // the display route for the menu item is the one for the referenced content item if(contentMenuItemPart != null) { + + // if the content doesn't exist anymore + if(contentMenuItemPart.Content == null) { + return; + } + context.Metadata.DisplayRouteValues = _contentManager.GetItemMetadata(contentMenuItemPart.Content).DisplayRouteValues; } } diff --git a/src/Orchard.Web/Core/Navigation/Module.txt b/src/Orchard.Web/Core/Navigation/Module.txt index 4497c9d28..f3471b576 100644 --- a/src/Orchard.Web/Core/Navigation/Module.txt +++ b/src/Orchard.Web/Core/Navigation/Module.txt @@ -2,8 +2,8 @@ AntiForgery: enabled Author: The Orchard Team Website: http://orchardproject.net -Version: 1.5.1 -OrchardVersion: 1.5.1 +Version: 1.6 +OrchardVersion: 1.6 Description: The navigation module creates and manages a simple navigation menu for the front-end of the application and allows you to add content items to the admin menu. FeatureDescription: Menu management. Category: Core diff --git a/src/Orchard.Web/Core/Reports/Module.txt b/src/Orchard.Web/Core/Reports/Module.txt index 85e63ae8f..db1546685 100644 --- a/src/Orchard.Web/Core/Reports/Module.txt +++ b/src/Orchard.Web/Core/Reports/Module.txt @@ -2,8 +2,8 @@ AntiForgery: enabled Author: The Orchard Team Website: http://orchardproject.net -Version: 1.5.1 -OrchardVersion: 1.5.1 +Version: 1.6 +OrchardVersion: 1.6 Description: The dashboard module is providing the reports screen of the application. FeatureDescription: Reports management. Category: Core diff --git a/src/Orchard.Web/Core/Scheduling/Module.txt b/src/Orchard.Web/Core/Scheduling/Module.txt index 9e97b93ad..b861c5d12 100644 --- a/src/Orchard.Web/Core/Scheduling/Module.txt +++ b/src/Orchard.Web/Core/Scheduling/Module.txt @@ -2,8 +2,8 @@ AntiForgery: enabled Author: The Orchard Team Website: http://orchardproject.net -Version: 1.5.1 -OrchardVersion: 1.5.1 +Version: 1.6 +OrchardVersion: 1.6 Description: The scheduling module enables background task scheduling. FeatureDescription: Scheduled background tasks. Category: Core diff --git a/src/Orchard.Web/Core/Settings/Module.txt b/src/Orchard.Web/Core/Settings/Module.txt index 0d586f229..fade5a7f4 100644 --- a/src/Orchard.Web/Core/Settings/Module.txt +++ b/src/Orchard.Web/Core/Settings/Module.txt @@ -2,8 +2,8 @@ AntiForgery: enabled Author: The Orchard Team Website: http://orchardproject.net -Version: 1.5.1 -OrchardVersion: 1.5.1 +Version: 1.6 +OrchardVersion: 1.6 Description: The settings module creates site settings that other modules can contribute to. FeatureDescription: Site settings. Category: Core diff --git a/src/Orchard.Web/Core/Shapes/Module.txt b/src/Orchard.Web/Core/Shapes/Module.txt index d21b5315c..25cffec02 100644 --- a/src/Orchard.Web/Core/Shapes/Module.txt +++ b/src/Orchard.Web/Core/Shapes/Module.txt @@ -2,8 +2,8 @@ AntiForgery: enabled Author: The Orchard Team Website: http://orchardproject.net -Version: 1.5.1 -OrchardVersion: 1.5.1 +Version: 1.6 +OrchardVersion: 1.6 Description: The shapes module contains core shape templates and display hooks. FeatureDescription: Core shape templates and display hooks. Category: Core diff --git a/src/Orchard.Web/Core/Title/Module.txt b/src/Orchard.Web/Core/Title/Module.txt index 973124ea1..6cfd7fbfa 100644 --- a/src/Orchard.Web/Core/Title/Module.txt +++ b/src/Orchard.Web/Core/Title/Module.txt @@ -2,8 +2,8 @@ AntiForgery: enabled Author: The Orchard Team Website: http://orchardproject.net -Version: 1.5.1 -OrchardVersion: 1.5.1 +Version: 1.6 +OrchardVersion: 1.6 Description: The title module enables content items to have titles. FeatureDescription: Title content part. Category: Core diff --git a/src/Orchard.Web/Core/XmlRpc/Module.txt b/src/Orchard.Web/Core/XmlRpc/Module.txt index 7979e8aaa..132993858 100644 --- a/src/Orchard.Web/Core/XmlRpc/Module.txt +++ b/src/Orchard.Web/Core/XmlRpc/Module.txt @@ -2,8 +2,8 @@ AntiForgery: enabled Author: The Orchard Team Website: http://orchardproject.net -Version: 1.5.1 -OrchardVersion: 1.5.1 +Version: 1.6 +OrchardVersion: 1.6 Description: The XmlRpc module enables creation of contents from client applications such as LiveWriter. FeatureDescription: XML-RPC opt-in implementation. Category: Content Publishing diff --git a/src/Orchard.Web/Modules/Orchard.Alias/Controllers/AdminController.cs b/src/Orchard.Web/Modules/Orchard.Alias/Controllers/AdminController.cs index 168f37e32..2ec60bb9f 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/Controllers/AdminController.cs +++ b/src/Orchard.Web/Modules/Orchard.Alias/Controllers/AdminController.cs @@ -22,7 +22,7 @@ namespace Orchard.Alias.Controllers { public AdminController( IAliasService aliasService, IOrchardServices orchardServices, - IAliasHolder aliasHolder ) { + IAliasHolder aliasHolder) { _aliasService = aliasService; _aliasHolder = aliasHolder; Services = orchardServices; @@ -65,7 +65,7 @@ namespace Orchard.Alias.Controllers { aliases = aliases.OrderBy(x => x.Path); break; } - + if (pager.PageSize != 0) { aliases = aliases.Skip(pager.GetStartIndex()).Take(pager.PageSize); } @@ -73,7 +73,7 @@ namespace Orchard.Alias.Controllers { var model = new AdminIndexViewModel { Options = options, Pager = pagerShape, - AliasEntries = aliases.Select(x => new AliasEntry() {Alias = x, IsChecked = false}).ToList() + AliasEntries = aliases.Select(x => new AliasEntry() { Alias = x, IsChecked = false }).ToList() }; return View(model); @@ -103,7 +103,7 @@ namespace Orchard.Alias.Controllers { throw new ArgumentOutOfRangeException(); } - return RedirectToAction("Index"); + return RedirectToAction("Index"); } public ActionResult Add() { @@ -118,7 +118,7 @@ namespace Orchard.Alias.Controllers { if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage aliases"))) return new HttpUnauthorizedResult(); - if(aliasPath == "/") { + if (aliasPath == "/") { aliasPath = String.Empty; } @@ -130,7 +130,7 @@ namespace Orchard.Alias.Controllers { ModelState.AddModelError("Route", T("Route can't be empty").Text); } - if(!ModelState.IsValid) { + if (!ModelState.IsValid) { return View(); } @@ -162,11 +162,11 @@ namespace Orchard.Alias.Controllers { var routeValues = _aliasService.Get(path); - if (routeValues==null) + if (routeValues == null) return HttpNotFound(); - var virtualPaths = _aliasService.LookupVirtualPaths(routeValues,HttpContext) - .Select(vpd=>vpd.VirtualPath); + var virtualPaths = _aliasService.LookupVirtualPaths(routeValues, HttpContext) + .Select(vpd => vpd.VirtualPath); ViewBag.AliasPath = path; ViewBag.RoutePath = virtualPaths.FirstOrDefault(); @@ -181,19 +181,18 @@ namespace Orchard.Alias.Controllers { // TODO: (PH:Autoroute) This could overwrite an existing Alias without warning, should handle this _aliasService.Set(aliasPath, routePath, "Custom"); - + // Remove previous alias - if (path != aliasPath) - { + if (path != aliasPath) { // TODO: (PH:Autoroute) Ability to fire an "AliasChanged" event so we make a redirect _aliasService.Delete(path); } Services.Notifier.Information(T("Alias {0} updated", path)); - + return RedirectToAction("Index"); } - + [HttpPost] public ActionResult Delete(string path) { if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage aliases"))) diff --git a/src/Orchard.Web/Modules/Orchard.Alias/IAliasService.cs b/src/Orchard.Web/Modules/Orchard.Alias/IAliasService.cs index aec3fcde1..6eb151cf2 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/IAliasService.cs +++ b/src/Orchard.Web/Modules/Orchard.Alias/IAliasService.cs @@ -2,10 +2,8 @@ using System.Collections.Generic; using System.Web.Routing; -namespace Orchard.Alias -{ - public interface IAliasService : IDependency - { +namespace Orchard.Alias { + public interface IAliasService : IDependency { RouteValueDictionary Get(string aliasPath); void Set(string aliasPath, RouteValueDictionary routeValues, string aliasSource); void Set(string aliasPath, string routePath, string aliasSource); @@ -24,7 +22,7 @@ namespace Orchard.Alias void Replace(string aliasPath, string routePath, string aliasSource); IEnumerable> List(); - IEnumerable> List(string sourceStartsWith); + IEnumerable> List(string sourceStartsWith); IEnumerable LookupVirtualPaths(RouteValueDictionary routeValues, System.Web.HttpContextBase HttpContext); } diff --git a/src/Orchard.Web/Modules/Orchard.Alias/Implementation/AliasRoute.cs b/src/Orchard.Web/Modules/Orchard.Alias/Implementation/AliasRoute.cs index 34bf1c6c2..2e7a3ace7 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/Implementation/AliasRoute.cs +++ b/src/Orchard.Web/Modules/Orchard.Alias/Implementation/AliasRoute.cs @@ -8,34 +8,33 @@ using System.Web.Routing; using Orchard.Alias.Implementation.Holder; using Orchard.Alias.Implementation.Map; -namespace Orchard.Alias.Implementation -{ - public class AliasRoute : RouteBase, IRouteWithArea - { +namespace Orchard.Alias.Implementation { + public class AliasRoute : RouteBase, IRouteWithArea { private readonly AliasMap _aliasMap; private readonly IRouteHandler _routeHandler; - public AliasRoute(IAliasHolder aliasHolder, string areaName, IRouteHandler routeHandler) - { + public AliasRoute(IAliasHolder aliasHolder, string areaName, IRouteHandler routeHandler) { Area = areaName; _aliasMap = aliasHolder.GetMap(areaName); _routeHandler = routeHandler; } - public override RouteData GetRouteData(HttpContextBase httpContext) - { + public override RouteData GetRouteData(HttpContextBase httpContext) { + // don't compute unnecessary virtual path if the map is empty + if (!_aliasMap.Any()) { + return null; + } + // Get the full inbound request path var virtualPath = httpContext.Request.AppRelativeCurrentExecutionFilePath.Substring(2) + httpContext.Request.PathInfo; // Attempt to lookup RouteValues in the alias map IDictionary routeValues; // TODO: Might as well have the lookup in AliasHolder... - if (_aliasMap.TryGetAlias(virtualPath, out routeValues)) - { + if (_aliasMap.TryGetAlias(virtualPath, out routeValues)) { // Construct RouteData from the route values var data = new RouteData(this, _routeHandler); - foreach (var routeValue in routeValues) - { + foreach (var routeValue in routeValues) { var key = routeValue.Key; if (key.EndsWith("-")) data.Values.Add(key.Substring(0, key.Length - 1), routeValue.Value); @@ -51,22 +50,19 @@ namespace Orchard.Alias.Implementation return null; } - public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary routeValues) - { + public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary routeValues) { // Lookup best match for route values in the expanded tree var match = _aliasMap.Locate(routeValues); - if (match != null) - { + if (match != null) { // Build any "spare" route values onto the Alias (so we correctly support any additional query parameters) var sb = new StringBuilder(match.Item2); var extra = 0; - foreach (var routeValue in routeValues) - { + foreach (var routeValue in routeValues) { // Ignore any we already have - if (match.Item1.ContainsKey(routeValue.Key)) - { + if (match.Item1.ContainsKey(routeValue.Key)) { continue; } + // Add a query string fragment sb.Append((extra++ == 0) ? '?' : '&'); sb.Append(Uri.EscapeDataString(routeValue.Key)); diff --git a/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Holder/AliasHolder.cs b/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Holder/AliasHolder.cs index 07697ab79..03157d3f1 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Holder/AliasHolder.cs +++ b/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Holder/AliasHolder.cs @@ -25,7 +25,7 @@ namespace Orchard.Alias.Implementation.Holder { } public void SetAlias(AliasInfo alias) { - foreach(var map in _aliasMaps.Values) { + foreach (var map in _aliasMaps.Values) { map.Remove(alias); } diff --git a/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Map/AliasMap.cs b/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Map/AliasMap.cs index bb0a631f4..834da797a 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Map/AliasMap.cs +++ b/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Map/AliasMap.cs @@ -53,6 +53,10 @@ namespace Orchard.Alias.Implementation.Map { CollapseTree(_root, info.Path, info.RouteValues); } + public bool Any() { + return _aliases.Any(); + } + private static void CollapseTree(Node root, string path, IDictionary routeValues) { foreach (var expanded in Expand(routeValues)) { var focus = root; @@ -96,14 +100,6 @@ namespace Orchard.Alias.Implementation.Map { return from item1 in source1 from item2 in source2 select produce(item1, item2); } - private static IEnumerable Single(T t) { - yield return t; - } - - private static IEnumerable Empty() { - return Enumerable.Empty(); - } - /// /// Expand the route values into all possible combinations of keys /// @@ -111,7 +107,7 @@ namespace Orchard.Alias.Implementation.Map { /// private static IEnumerable>> Expand(IDictionary routeValues) { var ordered = routeValues.OrderBy(kv => kv.Key, StringComparer.InvariantCultureIgnoreCase); - var empty = Empty>(); + var empty = Enumerable.Empty>(); // For each key/value pair, we want a list containing a single list with either the term, or the term and the "default" value var termSets = ordered.Select(term => { @@ -119,15 +115,15 @@ namespace Orchard.Alias.Implementation.Map { var termKey = term.Key.Substring(0, term.Key.Length - 1); return new[] { // This entry will auto-match in some cases because it was omitted from the route values - Single(new KeyValuePair(termKey, "\u0000")), - Single(new KeyValuePair(termKey, term.Value)) + new [] { new KeyValuePair(termKey, "\u0000") }, + new [] { new KeyValuePair(termKey, term.Value) } }; } return new[] {new[] {term}}; }); // Run each of those lists through an aggregation function, by taking the product of each set, so producting a tree of possibilities - var produced = termSets.Aggregate(Single(empty), (coords, termSet) => Product(coords, termSet, (coord, term) => coord.Concat(term))); + var produced = termSets.Aggregate(new[] { empty }.AsEnumerable(), (coords, termSet) => Product(coords, termSet, (coord, term) => coord.Concat(term))); return produced; } diff --git a/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Updater/AliasUpdater.cs b/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Updater/AliasUpdater.cs index fde8ae476..ec47459f0 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Updater/AliasUpdater.cs +++ b/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Updater/AliasUpdater.cs @@ -9,38 +9,33 @@ using Orchard.Environment; using Orchard.Tasks; using Orchard.Logging; -namespace Orchard.Alias.Implementation.Updater -{ - public class AliasHolderUpdater : IOrchardShellEvents, IBackgroundTask - { +namespace Orchard.Alias.Implementation.Updater { + public class AliasHolderUpdater : IOrchardShellEvents, IBackgroundTask { private readonly IAliasHolder _aliasHolder; private readonly IAliasStorage _storage; public ILogger Logger { get; set; } - public AliasHolderUpdater(IAliasHolder aliasHolder, IAliasStorage storage) - { + public AliasHolderUpdater(IAliasHolder aliasHolder, IAliasStorage storage) { _aliasHolder = aliasHolder; _storage = storage; Logger = NullLogger.Instance; } - void IOrchardShellEvents.Activated() - { + void IOrchardShellEvents.Activated() { Refresh(); } - void IOrchardShellEvents.Terminating() - { + void IOrchardShellEvents.Terminating() { } private void Refresh() { try { var aliases = _storage.List(); - _aliasHolder.SetAliases(aliases.Select(alias=>new AliasInfo{Path = alias.Item1, Area = alias.Item2, RouteValues=alias.Item3})); + _aliasHolder.SetAliases(aliases.Select(alias => new AliasInfo { Path = alias.Item1, Area = alias.Item2, RouteValues = alias.Item3 })); } - catch(Exception ex) { - Logger.Error(ex,"Exception during Alias refresh"); + catch (Exception ex) { + Logger.Error(ex, "Exception during Alias refresh"); } } diff --git a/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Utils.cs b/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Utils.cs index c8c1a6681..1f680be89 100644 --- a/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Utils.cs +++ b/src/Orchard.Web/Modules/Orchard.Alias/Implementation/Utils.cs @@ -8,15 +8,12 @@ using Orchard.Mvc.Extensions; using Orchard.Mvc.Routes; using Orchard.Mvc.Wrappers; -namespace Orchard.Alias.Implementation -{ - public static class Utils - { +namespace Orchard.Alias.Implementation { + public static class Utils { public static IDictionary LookupRouteValues - (HttpContextBase httpContext, IEnumerable - routeDescriptors, - string routePath) - { + (HttpContextBase httpContext, IEnumerable + routeDescriptors, + string routePath) { var queryStringIndex = routePath.IndexOf('?'); var routePathNoQueryString = queryStringIndex == -1 ? routePath : routePath.Substring(0, queryStringIndex); var queryString = queryStringIndex == -1 ? null : routePath.Substring(queryStringIndex + 1); @@ -51,8 +48,8 @@ namespace Orchard.Alias.Implementation public static IEnumerable LookupVirtualPaths( HttpContextBase httpContext, IEnumerable routeDescriptors, - string areaName, - IDictionary routeValues) { + string areaName, + IDictionary routeValues) { var routeValueDictionary = new RouteValueDictionary(routeValues.ToDictionary(kv => RemoveDash(kv.Key), kv => (object)kv.Value)); var virtualPathDatas = routeDescriptors.Where(r2 => r2.Route.GetAreaName() == areaName) @@ -68,26 +65,21 @@ namespace Orchard.Alias.Implementation } - private static Dictionary ToRouteValues(RouteData routeData, string queryString) - { + private static Dictionary ToRouteValues(RouteData routeData, string queryString) { var routeValues = routeData.Values - .Select(kv => - { + .Select(kv => { var value = Convert.ToString(kv.Value, CultureInfo.InvariantCulture); var defaultValue = FindDefault(routeData.Route, kv.Key); - if (defaultValue != null && string.Equals(defaultValue, value, StringComparison.InvariantCultureIgnoreCase)) - { + if (defaultValue != null && string.Equals(defaultValue, value, StringComparison.InvariantCultureIgnoreCase)) { return new { Key = kv.Key + "-", Value = value }; } return new { kv.Key, Value = value }; }) .ToDictionary(kv => kv.Key, kv => kv.Value); - if (queryString != null) - { + if (queryString != null) { foreach (var term in queryString .Split(new[] { "&" }, StringSplitOptions.RemoveEmptyEntries) - .Select(ParseTerm)) - { + .Select(ParseTerm)) { if (!routeValues.ContainsKey(term[0])) routeValues[term[0]] = term[1]; } @@ -95,75 +87,61 @@ namespace Orchard.Alias.Implementation return routeValues; } - private static string[] ParseTerm(string term) - { + private static string[] ParseTerm(string term) { var equalsIndex = term.IndexOf('='); - if (equalsIndex == -1) - { + if (equalsIndex == -1) { return new[] { Uri.UnescapeDataString(term), null }; } return new[] { Uri.UnescapeDataString(term.Substring(0, equalsIndex)), Uri.UnescapeDataString(term.Substring(equalsIndex + 1)) }; } - private static string FindDefault(RouteBase route, string key) - { + private static string FindDefault(RouteBase route, string key) { var route2 = route as Route; - if (route2 == null) - { + if (route2 == null) { return null; } object defaultValue; - if (!route2.Defaults.TryGetValue(key, out defaultValue)) - { + if (!route2.Defaults.TryGetValue(key, out defaultValue)) { return null; } return Convert.ToString(defaultValue, CultureInfo.InvariantCulture); } - public class LookupHttpContext : HttpContextBaseWrapper - { + public class LookupHttpContext : HttpContextBaseWrapper { private readonly string _path; public LookupHttpContext(HttpContextBase httpContext, string path) - : base(httpContext) - { + : base(httpContext) { _path = path; } - public override HttpRequestBase Request - { + public override HttpRequestBase Request { get { return new LookupHttpRequest(this, base.Request, _path); } } - private class LookupHttpRequest : HttpRequestBaseWrapper - { + private class LookupHttpRequest : HttpRequestBaseWrapper { private readonly string _path; public LookupHttpRequest(HttpContextBase httpContextBase, HttpRequestBase httpRequestBase, string path) - : base( /*httpContextBase,*/ httpRequestBase) - { + : base( /*httpContextBase,*/ httpRequestBase) { _path = path; } - public override string AppRelativeCurrentExecutionFilePath - { + public override string AppRelativeCurrentExecutionFilePath { get { return "~/" + _path; } } - public override string ApplicationPath - { + public override string ApplicationPath { get { return "/"; } } - public override string Path - { + public override string Path { get { return "/" + _path; } } - public override string PathInfo - { + public override string PathInfo { get { return ""; } } } diff --git a/src/Orchard.Web/Modules/Orchard.Autoroute/Drivers/AutoroutePartDriver.cs b/src/Orchard.Web/Modules/Orchard.Autoroute/Drivers/AutoroutePartDriver.cs index db8932b1c..82c231b5c 100644 --- a/src/Orchard.Web/Modules/Orchard.Autoroute/Drivers/AutoroutePartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.Autoroute/Drivers/AutoroutePartDriver.cs @@ -98,7 +98,7 @@ namespace Orchard.Autoroute.Drivers { if (path.StartsWith(".") || path.EndsWith(".")) updater.AddModelError("CurrentUrl", T("The \".\" can't be used at either end of the permalink.")); else - updater.AddModelError("CurrentUrl", 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("CurrentUrl", T("Please do not use any of the following characters in your permalink: \":\", \"?\", \"#\", \"[\", \"]\", \"@\", \"!\", \"$\", \"&\", \"'\", \"(\", \")\", \"*\", \"+\", \",\", \";\", \"=\", \", \"<\", \">\", \"\\\", \"|\". No spaces are allowed (please use dashes or underscores instead).")); } // if CurrentUrl is set, the handler won't try to create an alias for it diff --git a/src/Orchard.Web/Modules/Orchard.Autoroute/Services/AutorouteService.cs b/src/Orchard.Web/Modules/Orchard.Autoroute/Services/AutorouteService.cs index 7ec41f9f5..b30ab6b5d 100644 --- a/src/Orchard.Web/Modules/Orchard.Autoroute/Services/AutorouteService.cs +++ b/src/Orchard.Web/Modules/Orchard.Autoroute/Services/AutorouteService.cs @@ -166,7 +166,7 @@ namespace Orchard.Autoroute.Services { } public bool IsPathValid(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 ProcessPath(AutoroutePart part) { diff --git a/src/Orchard.Web/Modules/Orchard.Autoroute/Services/DefaultSlugService.cs b/src/Orchard.Web/Modules/Orchard.Autoroute/Services/DefaultSlugService.cs index 40a6befdf..58ead540a 100644 --- a/src/Orchard.Web/Modules/Orchard.Autoroute/Services/DefaultSlugService.cs +++ b/src/Orchard.Web/Modules/Orchard.Autoroute/Services/DefaultSlugService.cs @@ -7,7 +7,7 @@ namespace Orchard.Autoroute.Services { public class DefaultSlugService : ISlugService { private readonly ISlugEventHandler _slugEventHandler; - + public DefaultSlugService( ISlugEventHandler slugEventHander ) { @@ -26,7 +26,7 @@ namespace Orchard.Autoroute.Services { if (!slugContext.Adjusted) { - var disallowed = new Regex(@"[/:?#\[\]@!$&'()*+,;=\s\""\<\>\\]+"); + var disallowed = new Regex(@"[/:?#\[\]@!$&'()*+,;=\s\""\<\>\\\|]+"); slugContext.Slug = disallowed.Replace(slugContext.Title, "-").Trim('-','.'); diff --git a/src/Orchard.Web/Modules/Orchard.CustomForms/Controllers/ItemController.cs b/src/Orchard.Web/Modules/Orchard.CustomForms/Controllers/ItemController.cs index ad94a6a3f..5c3e14edf 100644 --- a/src/Orchard.Web/Modules/Orchard.CustomForms/Controllers/ItemController.cs +++ b/src/Orchard.Web/Modules/Orchard.CustomForms/Controllers/ItemController.cs @@ -131,8 +131,9 @@ namespace Orchard.CustomForms.Controllers { foreach (var error in ModelState.Values.SelectMany(m => m.Errors).Select(e => e.ErrorMessage)) { Services.Notifier.Error(T(error)); } + if (returnUrl != null) { - return Redirect(returnUrl); + return this.RedirectLocal(returnUrl); } } @@ -165,7 +166,8 @@ namespace Orchard.CustomForms.Controllers { } } - return this.RedirectLocal(returnUrl, () => Redirect(Request.RawUrl)); + var referrer = Request.UrlReferrer != null ? Request.UrlReferrer.ToString() : null; + return this.RedirectLocal(returnUrl, () => this.RedirectLocal(referrer, () => Redirect(Request.RawUrl))); } bool IUpdateModel.TryUpdateModel(TModel model, string prefix, string[] includeProperties, string[] excludeProperties) { diff --git a/src/Orchard.Web/Modules/Orchard.CustomForms/Drivers/CustomFormPartDriver.cs b/src/Orchard.Web/Modules/Orchard.CustomForms/Drivers/CustomFormPartDriver.cs index 85a163fde..f73a1d889 100644 --- a/src/Orchard.Web/Modules/Orchard.CustomForms/Drivers/CustomFormPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.CustomForms/Drivers/CustomFormPartDriver.cs @@ -33,8 +33,7 @@ namespace Orchard.CustomForms.Drivers { return ContentShape("Parts_CustomForm_Wrapper", () => { return shapeHelper.Parts_CustomForm_Wrapper() .Editor(_orchardServices.ContentManager.BuildEditor(contentItem)) - .ContenItem(part) - .ReturnUrl(part.Redirect ? part.RedirectUrl : _orchardServices.WorkContext.HttpContext.Request.RawUrl); + .ContenItem(part); }); } diff --git a/src/Orchard.Web/Modules/Orchard.CustomForms/Views/Parts.CustomForm.Wrapper.cshtml b/src/Orchard.Web/Modules/Orchard.CustomForms/Views/Parts.CustomForm.Wrapper.cshtml index 04f86083d..1958370b6 100644 --- a/src/Orchard.Web/Modules/Orchard.CustomForms/Views/Parts.CustomForm.Wrapper.cshtml +++ b/src/Orchard.Web/Modules/Orchard.CustomForms/Views/Parts.CustomForm.Wrapper.cshtml @@ -2,7 +2,6 @@ @{ ContentItem customForm = Model.ContentItem; - string returnUrl = Model.ReturnUrl; // remove default Save/Publish buttons Model.Editor.Zones["Sidebar"].Items.Clear(); @@ -13,7 +12,7 @@ // Model is a Shape, calling Display() so that it is rendered using the most specific template for its Shape type @Display(Model.Editor) - @Html.Hidden("returnUrl", returnUrl); + @Html.Hidden("returnUrl", Request.RawUrl);
diff --git a/src/Orchard.Web/Modules/Orchard.DesignerTools/Views/ShapeTracingMeta.cshtml b/src/Orchard.Web/Modules/Orchard.DesignerTools/Views/ShapeTracingMeta.cshtml index 35fd81c30..aec01fffc 100644 --- a/src/Orchard.Web/Modules/Orchard.DesignerTools/Views/ShapeTracingMeta.cshtml +++ b/src/Orchard.Web/Modules/Orchard.DesignerTools/Views/ShapeTracingMeta.cshtml @@ -67,7 +67,7 @@ shapeTracingMetadataHost[@Model.ShapeId].shape = { @if (!String.IsNullOrEmpty((string)Model.PlacementSource) && (WorkContext.HttpContext.Items[(string)Model.PlacementSource] == null)) { WorkContext.HttpContext.Items[(string)Model.PlacementSource] = new object(); -shapeTracingMetadataHost.placement['@Model.PlacementSource.ToString()'] = '@ShapeTracingFactory.FormatJsonValue((string)Model.PlacementContent)'; +shapeTracingMetadataHost.placement['@Model.PlacementSource.ToString()'] = '@HttpUtility.JavaScriptStringEncode((string)Model.PlacementContent)'; } diff --git a/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/MediaPicker.Edit.cshtml b/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/MediaPicker.Edit.cshtml index 5dc9d3f53..7cae15dd6 100644 --- a/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/MediaPicker.Edit.cshtml +++ b/src/Orchard.Web/Modules/Orchard.Fields/Views/EditorTemplates/Fields/MediaPicker.Edit.cshtml @@ -21,14 +21,13 @@ @Html.HiddenFor(m => m.Class) @Html.HiddenFor(m => m.Style) @Html.HiddenFor(m => m.Alignment) - @Html.HiddenFor(m => m.Alignment) @Html.HiddenFor(m => m.Width) @Html.HiddenFor(m => m.Height)
-@using (Script.Foot()) -{ +@using (Script.Foot()) { +