mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Fix issue with virtual paths
~/Foo is the same as /Foo only if the application virtual path is "/". Otherwise, "~/Foo" is equal to "/AppPath/Foo". --HG-- branch : dev
This commit is contained in:
@@ -2,6 +2,7 @@ using System;
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
using System.Web.Hosting;
|
using System.Web.Hosting;
|
||||||
using Orchard.Environment.Extensions.Loaders;
|
using Orchard.Environment.Extensions.Loaders;
|
||||||
using Orchard.FileSystems.VirtualPath;
|
using Orchard.FileSystems.VirtualPath;
|
||||||
@@ -11,7 +12,7 @@ namespace Orchard.FileSystems.Dependencies {
|
|||||||
public class DynamicModuleVirtualPathProvider : VirtualPathProvider, ICustomVirtualPathProvider {
|
public class DynamicModuleVirtualPathProvider : VirtualPathProvider, ICustomVirtualPathProvider {
|
||||||
private readonly IDependenciesFolder _dependenciesFolder;
|
private readonly IDependenciesFolder _dependenciesFolder;
|
||||||
private readonly IEnumerable<IExtensionLoader> _loaders;
|
private readonly IEnumerable<IExtensionLoader> _loaders;
|
||||||
private readonly string[] _modulesPrefixes = { "~/Modules/", "/Modules/" };
|
private readonly string[] _modulesPrefixes = { "~/Modules/" };
|
||||||
|
|
||||||
public DynamicModuleVirtualPathProvider(IDependenciesFolder dependenciesFolder, IEnumerable<IExtensionLoader> loaders) {
|
public DynamicModuleVirtualPathProvider(IDependenciesFolder dependenciesFolder, IEnumerable<IExtensionLoader> loaders) {
|
||||||
_dependenciesFolder = dependenciesFolder;
|
_dependenciesFolder = dependenciesFolder;
|
||||||
@@ -66,11 +67,12 @@ namespace Orchard.FileSystems.Dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private DependencyDescriptor GetDependencyDescriptor(string virtualPath) {
|
private DependencyDescriptor GetDependencyDescriptor(string virtualPath) {
|
||||||
var prefix = PrefixMatch(virtualPath, _modulesPrefixes);
|
var appRelativePath = VirtualPathUtility.ToAppRelative(virtualPath);
|
||||||
|
var prefix = PrefixMatch(appRelativePath, _modulesPrefixes);
|
||||||
if (prefix == null)
|
if (prefix == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var moduleName = ModuleMatch(virtualPath, prefix);
|
var moduleName = ModuleMatch(appRelativePath, prefix);
|
||||||
if (moduleName == null)
|
if (moduleName == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
using System.Web.Hosting;
|
using System.Web.Hosting;
|
||||||
using Orchard.Environment.Extensions.Loaders;
|
using Orchard.Environment.Extensions.Loaders;
|
||||||
using Orchard.FileSystems.VirtualPath;
|
using Orchard.FileSystems.VirtualPath;
|
||||||
@@ -11,8 +12,8 @@ namespace Orchard.FileSystems.Dependencies {
|
|||||||
public class WebFormVirtualPathProvider : VirtualPathProvider, ICustomVirtualPathProvider {
|
public class WebFormVirtualPathProvider : VirtualPathProvider, ICustomVirtualPathProvider {
|
||||||
private readonly IDependenciesFolder _dependenciesFolder;
|
private readonly IDependenciesFolder _dependenciesFolder;
|
||||||
private readonly IEnumerable<IExtensionLoader> _loaders;
|
private readonly IEnumerable<IExtensionLoader> _loaders;
|
||||||
private readonly string[] _modulesPrefixes = { "~/Modules/", "/Modules/" };
|
private readonly string[] _modulesPrefixes = { "~/Modules/" };
|
||||||
private readonly string[] _themesPrefixes = { "~/Themes/", "/Themes/" };
|
private readonly string[] _themesPrefixes = { "~/Themes/" };
|
||||||
private readonly string[] _extensions = { ".ascx", ".aspx", ".master" };
|
private readonly string[] _extensions = { ".ascx", ".aspx", ".master" };
|
||||||
|
|
||||||
public WebFormVirtualPathProvider(IDependenciesFolder dependenciesFolder, IEnumerable<IExtensionLoader> loaders) {
|
public WebFormVirtualPathProvider(IDependenciesFolder dependenciesFolder, IEnumerable<IExtensionLoader> loaders) {
|
||||||
@@ -98,15 +99,16 @@ namespace Orchard.FileSystems.Dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private VirtualFileOverride GetModuleVirtualOverride(string virtualPath) {
|
private VirtualFileOverride GetModuleVirtualOverride(string virtualPath) {
|
||||||
var prefix = PrefixMatch(virtualPath, _modulesPrefixes);
|
var appRelativePath = VirtualPathUtility.ToAppRelative(virtualPath);
|
||||||
|
var prefix = PrefixMatch(appRelativePath, _modulesPrefixes);
|
||||||
if (prefix == null)
|
if (prefix == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var extension = ExtensionMatch(virtualPath, _extensions);
|
var extension = ExtensionMatch(appRelativePath, _extensions);
|
||||||
if (extension == null)
|
if (extension == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var moduleName = ModuleMatch(virtualPath, prefix);
|
var moduleName = ModuleMatch(appRelativePath, prefix);
|
||||||
if (moduleName == null)
|
if (moduleName == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@@ -130,11 +132,12 @@ namespace Orchard.FileSystems.Dependencies {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private VirtualFileOverride GetThemeVirtualOverride(string virtualPath) {
|
private VirtualFileOverride GetThemeVirtualOverride(string virtualPath) {
|
||||||
var prefix = PrefixMatch(virtualPath, _themesPrefixes);
|
var appRelativePath = VirtualPathUtility.ToAppRelative(virtualPath);
|
||||||
|
var prefix = PrefixMatch(appRelativePath, _themesPrefixes);
|
||||||
if (prefix == null)
|
if (prefix == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var extension = ExtensionMatch(virtualPath, _extensions);
|
var extension = ExtensionMatch(appRelativePath, _extensions);
|
||||||
if (extension == null)
|
if (extension == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user