mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Merge
--HG-- branch : 1.x
This commit is contained in:
@@ -72,7 +72,7 @@ namespace Orchard.Core.Tests.Routable.Services {
|
||||
|
||||
var thing = contentManager.Create<Thing>("thing", t => {
|
||||
t.As<RoutePart>().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<RoutePart>());
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Xml;
|
||||
|
||||
using log4net.Appender;
|
||||
using log4net.Core;
|
||||
using log4net.ObjectRenderer;
|
||||
@@ -154,17 +153,12 @@ namespace Orchard.Logging {
|
||||
LogLog.Debug("XmlHierarchyConfigurator: Configuration reset before reading config.");
|
||||
}
|
||||
|
||||
// Try to retrieve the environment variables
|
||||
try {
|
||||
// The Log4netFactory/OrchardXmlConfigurator/OrchardXmlHierarchyConfigurator can be refactored later
|
||||
// so we call HostEnvironment.IsFullTrust
|
||||
if (AppDomain.CurrentDomain.IsHomogenous && AppDomain.CurrentDomain.IsFullyTrusted)
|
||||
_environmentVariables = System.Environment.GetEnvironmentVariables();
|
||||
}
|
||||
catch (System.Security.SecurityException) {
|
||||
else {
|
||||
_environmentVariables = null;
|
||||
|
||||
// This security exception will occur if the caller does not have
|
||||
// unrestricted environment permission. If this occurs the expansion
|
||||
// will be skipped with the following warning message.
|
||||
LogLog.Debug("XmlHierarchyConfigurator: Security exception while trying to expand environment variables. Error Ignored. No Expansion.");
|
||||
}
|
||||
|
||||
/* Building Appender objects, placing them in a local namespace
|
||||
|
||||
@@ -74,7 +74,18 @@ namespace Orchard.UI.Resources {
|
||||
}
|
||||
|
||||
public RequireSettings Define(Action<ResourceDefinition> resourceDefinition) {
|
||||
InlineDefinition = resourceDefinition ?? InlineDefinition;
|
||||
if (resourceDefinition != null) {
|
||||
var previous = InlineDefinition;
|
||||
if (previous != null) {
|
||||
InlineDefinition = r => {
|
||||
previous(r);
|
||||
resourceDefinition(r);
|
||||
};
|
||||
}
|
||||
else {
|
||||
InlineDefinition = resourceDefinition;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace Orchard.UI.Resources {
|
||||
return tagBuilder;
|
||||
}
|
||||
|
||||
public static void WriteResource(TextWriter writer, ResourceDefinition resource, string url, string condition, Dictionary<string,string> attributes) {
|
||||
public static void WriteResource(TextWriter writer, ResourceDefinition resource, string url, string condition, Dictionary<string, string> attributes) {
|
||||
if (!string.IsNullOrEmpty(condition)) {
|
||||
writer.WriteLine("<!--[if " + condition + "]>");
|
||||
}
|
||||
@@ -81,7 +81,7 @@ namespace Orchard.UI.Resources {
|
||||
var builder = new ResourceManifestBuilder();
|
||||
foreach (var provider in _providers) {
|
||||
builder.Feature = provider.Metadata.ContainsKey("Feature") ?
|
||||
(Feature) provider.Metadata["Feature"] :
|
||||
(Feature)provider.Metadata["Feature"] :
|
||||
null;
|
||||
provider.Value.BuildManifests(builder);
|
||||
}
|
||||
@@ -107,7 +107,7 @@ namespace Orchard.UI.Resources {
|
||||
RequireSettings settings;
|
||||
var key = new Tuple<string, string>(resourceType, resourceName);
|
||||
if (!_required.TryGetValue(key, out settings)) {
|
||||
settings = new RequireSettings {Type = resourceType, Name = resourceName};
|
||||
settings = new RequireSettings { Type = resourceType, Name = resourceName };
|
||||
_required[key] = settings;
|
||||
}
|
||||
_builtResources[resourceType] = null;
|
||||
@@ -162,6 +162,10 @@ namespace Orchard.UI.Resources {
|
||||
}
|
||||
|
||||
public virtual ResourceDefinition FindResource(RequireSettings settings) {
|
||||
return FindResource(settings, true);
|
||||
}
|
||||
|
||||
private ResourceDefinition FindResource(RequireSettings settings, bool resolveInlineDefinitions) {
|
||||
// find the resource with the given type and name
|
||||
// that has at least the given version number. If multiple,
|
||||
// return the resource with the greatest version number.
|
||||
@@ -180,19 +184,35 @@ namespace Orchard.UI.Resources {
|
||||
orderby r.Value.Version descending
|
||||
select r.Value).FirstOrDefault();
|
||||
}
|
||||
if (resource == null && settings.InlineDefinition != null) {
|
||||
// defining it on the fly
|
||||
resource = DynamicResources.DefineResource(type, name)
|
||||
.SetBasePath(settings.BasePath);
|
||||
settings.InlineDefinition(resource);
|
||||
if (resolveInlineDefinitions && resource == null) {
|
||||
// Does not seem to exist, but it's possible it is being
|
||||
// defined by a Define() from a RequireSettings somewhere.
|
||||
if (ResolveInlineDefinitions(settings.Type)) {
|
||||
// if any were defined, now try to find it
|
||||
resource = FindResource(settings, false);
|
||||
}
|
||||
}
|
||||
return resource;
|
||||
}
|
||||
|
||||
private bool ResolveInlineDefinitions(string resourceType) {
|
||||
bool anyWereDefined = false;
|
||||
foreach (var settings in GetRequiredResources(resourceType).Where(settings => settings.InlineDefinition != null)) {
|
||||
// defining it on the fly
|
||||
var resource = FindResource(settings, false);
|
||||
if (resource == null) {
|
||||
// does not already exist, so define it
|
||||
resource = DynamicResources.DefineResource(resourceType, settings.Name).SetBasePath(settings.BasePath);
|
||||
anyWereDefined = true;
|
||||
}
|
||||
settings.InlineDefinition(resource);
|
||||
settings.InlineDefinition = null;
|
||||
}
|
||||
return anyWereDefined;
|
||||
}
|
||||
|
||||
public virtual IEnumerable<RequireSettings> GetRequiredResources(string type) {
|
||||
return from r in _required
|
||||
where r.Key.Item1 == type
|
||||
select r.Value;
|
||||
return _required.Where(r => r.Key.Item1 == type).Select(r => r.Value);
|
||||
}
|
||||
|
||||
public virtual IList<LinkEntry> GetRegisteredLinks() {
|
||||
@@ -225,7 +245,7 @@ namespace Orchard.UI.Resources {
|
||||
ExpandDependencies(resource, settings, allResources);
|
||||
}
|
||||
requiredResources = (from DictionaryEntry entry in allResources
|
||||
select new ResourceRequiredContext {Resource = (ResourceDefinition) entry.Key, Settings = (RequireSettings) entry.Value}).ToList();
|
||||
select new ResourceRequiredContext { Resource = (ResourceDefinition)entry.Key, Settings = (RequireSettings)entry.Value }).ToList();
|
||||
_builtResources[resourceType] = requiredResources;
|
||||
return requiredResources;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user