From 4c90cd1ceaf8dc747be8c324e45118efe80e13de Mon Sep 17 00:00:00 2001 From: Sacha Trauwaen Date: Sat, 22 Nov 2014 22:26:36 +0100 Subject: [PATCH] v 1.3 --- HttpModules/FriendlyUrlProvider.cs | 9 +- HttpModules/UrlRewriteModule.cs | 16 +- HttpModules/UrlRewriteModuleUtils.cs | 190 ++++++++++++------ OpenUrlRewriter71.csproj | 23 ++- .../OpenUrlRewriterSitemapProvider.cs | 19 +- Providers/UrlRuleProviders/UrlBuilder.cs | 43 ++-- Providers/UrlRuleProviders/UrlRule.cs | 2 +- 7 files changed, 190 insertions(+), 112 deletions(-) diff --git a/HttpModules/FriendlyUrlProvider.cs b/HttpModules/FriendlyUrlProvider.cs index 4a31b18..6e716c3 100644 --- a/HttpModules/FriendlyUrlProvider.cs +++ b/HttpModules/FriendlyUrlProvider.cs @@ -182,13 +182,12 @@ public override string FriendlyUrl(TabInfo tab, string path, string pageName, st } if (!string.IsNullOrEmpty(CultureCode)) { - var primaryAliases = DotNetNuke.Entities.Portals.Internal.TestablePortalAliasController.Instance.GetPortalAliasesByPortalId(PortalId).ToList(); - var alias = primaryAliases.FirstOrDefault(a => a.CultureCode == CultureCode); + var primaryAliases = DotNetNuke.Entities.Portals.Internal.TestablePortalAliasController.Instance.GetPortalAliasesByPortalId(PortalId).ToList().Where(a => a.IsPrimary == true); + var alias = primaryAliases.FirstOrDefault(a => string.Equals(a.CultureCode, CultureCode, StringComparison.InvariantCultureIgnoreCase) ); if (alias != null) { portalAlias = alias.HTTPAlias; - } - - + DefaultPortalAlias = portalAlias; + } var DefaultAlias = primaryAliases.FirstOrDefault(a => string.IsNullOrEmpty(a.CultureCode)); if (DefaultAlias != null) { diff --git a/HttpModules/UrlRewriteModule.cs b/HttpModules/UrlRewriteModule.cs index 96fb874..3ac68f9 100644 --- a/HttpModules/UrlRewriteModule.cs +++ b/HttpModules/UrlRewriteModule.cs @@ -154,15 +154,14 @@ private void RewriteUrl(HttpApplication app, out string portalAlias) { app.Response.End(); } else if (action.DoRedirect) { app.Context.Items.Add("UrlRewrite:RedirectUrl", action.RedirectUrl); - + app.Response.AppendHeader("X-Redirect-Reason", action.Raison); if (action.Status == 302) - { + { app.Response.Redirect(action.RedirectUrl, true); } else { - app.Response.Status = "301 Moved Permanently"; - app.Response.AppendHeader("X-Redirect-Reason", action.Raison); + app.Response.Status = "301 Moved Permanently"; app.Response.AddHeader("Location", action.RedirectUrl); app.Response.End(); } @@ -313,6 +312,7 @@ public void OnBeginRequest(object s, EventArgs e) if (childAlias.IndexOf(domainName, StringComparison.OrdinalIgnoreCase) == -1) { //redirect to the url defined in the alias + app.Response.AppendHeader("X-Redirect-Reason", "alias parameter"); response.Redirect(Globals.GetPortalDomainName(childAlias, request, true), true); } else //the alias is the same as the current domain @@ -357,6 +357,7 @@ public void OnBeginRequest(object s, EventArgs e) { strURL += app.Request.Url.PathAndQuery; } + app.Response.AppendHeader("X-Redirect-Reason", "not correct domain"); response.Redirect(strURL, true); } } @@ -398,7 +399,7 @@ public void OnBeginRequest(object s, EventArgs e) portalAliasInfo.PortalID = portalId; portalAliasInfo.HTTPAlias = portalAlias; portalAliasController.AddPortalAlias(portalAliasInfo); - + app.Response.AppendHeader("X-Redirect-Reason", "auto add portalalis"); response.Redirect(app.Request.Url.ToString(), true); } } @@ -451,7 +452,7 @@ public void OnBeginRequest(object s, EventArgs e) { redirectUrl = redirectAlias + redirectUrl.Substring(checkAlias.Length); } - + app.Response.AppendHeader("X-Redirect-Reason", "alias redirect"); response.AppendHeader("Location", redirectUrl); } @@ -461,9 +462,11 @@ public void OnBeginRequest(object s, EventArgs e) { //Target Url var redirectUrl = portalSettings.ActiveTab.FullUrl; + app.Response.AppendHeader("X-Redirect-Reason", "page url redirect"); if (portalSettings.ActiveTab.PermanentRedirect) { //Permanently Redirect + response.StatusCode = 301; response.AppendHeader("Location", redirectUrl); } @@ -511,6 +514,7 @@ public void OnBeginRequest(object s, EventArgs e) if (strURL.StartsWith("https://", StringComparison.InvariantCultureIgnoreCase)) { //redirect to secure connection + app.Response.AppendHeader("X-Redirect-Reason", "redirect to secure"); response.Redirect(strURL, true); } else //when switching to an unsecure page, use a clientside redirector to avoid the browser security warning diff --git a/HttpModules/UrlRewriteModuleUtils.cs b/HttpModules/UrlRewriteModuleUtils.cs index 25783d3..adb28a7 100644 --- a/HttpModules/UrlRewriteModuleUtils.cs +++ b/HttpModules/UrlRewriteModuleUtils.cs @@ -34,8 +34,8 @@ public static void RewriteUrl(HttpApplication app, out string portalAlias, out P { HttpRequest request = app.Request; HttpResponse response = app.Response; - - RewriteUrl(app, request.Url, out portalAlias, out objPortalAlias, out action, + + RewriteUrl(app, request.Url, out portalAlias, out objPortalAlias, out action, request.ApplicationPath, request.IsSecureConnection, request.HttpMethod, request.RawUrl, request.PhysicalPath); } @@ -47,7 +47,7 @@ public static void RewriteUrl(Uri url, out string portalAlias, out PortalAliasIn } #endregion - private static void RewriteUrl(HttpApplication app, Uri url, out string portalAlias, out PortalAliasInfo objPortalAlias, out RewriterAction action, + private static void RewriteUrl(HttpApplication app, Uri url, out string portalAlias, out PortalAliasInfo objPortalAlias, out RewriterAction action, string applicationPath, bool isSecureConnection, string httpMethod, string rawUrl, string PhysicalPath) { /* @@ -85,12 +85,9 @@ private static void RewriteUrl(HttpApplication app, Uri url, out string portalAl portalAlias = ""; //determine portal alias looking for longest possible match objPortalAlias = GetPortalAlias(url, out portalAlias); - - - - // action is the object containing all info about rewiting and redirection action = new RewriterAction(); + if (objPortalAlias == null) return; action.LocalPath = url.LocalPath; action.HostPort = GetHostPort(url, isSecureConnection); action.OriginalUrl = action.HostPort + action.LocalPath; @@ -188,57 +185,80 @@ private static void RewriteUrl(HttpApplication app, Uri url, out string portalAl ProcessRedirect(app, httpMethod, url, action); return; } - #if DNN71 else if (!string.IsNullOrEmpty(objPortalAlias.CultureCode)) { - var primaryAliases = DotNetNuke.Entities.Portals.Internal.TestablePortalAliasController.Instance.GetPortalAliasesByPortalId(objPortalAlias.PortalID).ToList(); + var primaryAliases = DotNetNuke.Entities.Portals.Internal.TestablePortalAliasController.Instance.GetPortalAliasesByPortalId(objPortalAlias.PortalID).ToList().Where(a => a.IsPrimary == true); var alias = primaryAliases.FirstOrDefault(a => string.IsNullOrEmpty(a.CultureCode)); if (alias != null) { action.Alias = alias.HTTPAlias; + action.DoRedirect = true; + action.Raison += "+Remove language"; + action.RedirectHomePage = true; + ProcessRedirect(app, httpMethod, url, action); + return; } - action.DoRedirect = true; - action.Raison += "+Remove language"; - action.RedirectHomePage = true; - ProcessRedirect(app, httpMethod, url, action); - return; - } - -#endif - else - { - PortalController pc = new PortalController(); + // for url www.mysite.com/nl : redirect to www.mysite.com/nl/home Locale DefaultLocale = LocaleController.Instance.GetDefaultLocale(portalID); - string ActiveLanguage = PortalController.GetActivePortalLanguage(portalID); - if (ActiveLanguage != DefaultLocale.Code) // Browser language detection + if (!string.IsNullOrEmpty(objPortalAlias.CultureCode) && (objPortalAlias.CultureCode != DefaultLocale.Code)) { - PortalInfo objPortal = pc.GetPortal(portalID, ActiveLanguage); + PortalController pc = new PortalController(); + + PortalInfo objPortal = pc.GetPortal(portalID, objPortalAlias.CultureCode); if (objPortal.HomeTabId > 0) { var portalSettings = new PortalSettings(objPortal.HomeTabId, objPortalAlias); - app.Context.Items.Add("UrlRewrite:OriginalUrl", app.Request.Url.AbsoluteUri); - string HomeUrl = Globals.NavigateURL(objPortal.HomeTabId, false, portalSettings, "", ActiveLanguage); + string HomeUrl = Globals.NavigateURL(objPortal.HomeTabId, false, portalSettings, "", objPortalAlias.CultureCode); app.Context.Items.Remove("UrlRewrite:OriginalUrl"); action.DoRedirect = true; - action.Raison += "+Active language"; - action.Status = 302; + action.Raison += "+Home page missing"; + action.Status = 301; action.RedirectHomePage = true; action.RedirectUrl = HomeUrl; return; } } - + + } + +#endif + { + PortalController pc = new PortalController(); + Locale DefaultLocale = LocaleController.Instance.GetDefaultLocale(portalID); + // Browser language detection + if (HttpContext.Current.Request["language"] == null && EnableBrowserLanguageInDefault(portalID)) + { + string ActiveLanguage = PortalController.GetActivePortalLanguage(portalID); + if (ActiveLanguage != DefaultLocale.Code) + { + PortalInfo objPortal = pc.GetPortal(portalID, ActiveLanguage); + if (objPortal.HomeTabId > 0) + { + var portalSettings = new PortalSettings(objPortal.HomeTabId, objPortalAlias); + + app.Context.Items.Add("UrlRewrite:OriginalUrl", app.Request.Url.AbsoluteUri); + string HomeUrl = Globals.NavigateURL(objPortal.HomeTabId, false, portalSettings, "", ActiveLanguage); + app.Context.Items.Remove("UrlRewrite:OriginalUrl"); + action.DoRedirect = true; + action.Raison += "+Active language"; + action.Status = 302; + action.RedirectHomePage = true; + action.RedirectUrl = HomeUrl; + return; + } + } + } { PortalInfo objPortal = pc.GetPortal(portalID, DefaultLocale.Code); + string sendToUrl = "~/" + Globals.glbDefaultPage + "?TabID=" + objPortal.HomeTabId; if (dicLocales.Count > 1) { sendToUrl = sendToUrl + "&language=" + objPortal.DefaultLanguage; } - if (!string.IsNullOrEmpty(action.QueryUrl)) { sendToUrl = sendToUrl + "&" + action.QueryUrl.TrimStart('?', '&'); @@ -253,25 +273,25 @@ private static void RewriteUrl(HttpApplication app, Uri url, out string portalAl return; } } - } - #if DNN71 - if (action.WorkUrl == "" && !string.IsNullOrEmpty(action.CultureCode)) - { - - PortalInfo objPortal = new PortalController().GetPortal(portalID, action.CultureCode); - string sendToUrl = "~/" + Globals.glbDefaultPage + "?TabID=" + objPortal.HomeTabId; - sendToUrl = sendToUrl + "&language=" + action.CultureCode; - if (app != null) + if (!string.IsNullOrEmpty(action.CultureCode)) { - app.Context.Items.Add("UrlRewrite:RewriteUrl", RewriterUtils.ResolveUrl(applicationPath, sendToUrl)); + + PortalInfo objPortal = new PortalController().GetPortal(portalID, action.CultureCode); + string sendToUrl = "~/" + Globals.glbDefaultPage + "?TabID=" + objPortal.HomeTabId; + sendToUrl = sendToUrl + "&language=" + action.CultureCode; + if (app != null) + { + app.Context.Items.Add("UrlRewrite:RewriteUrl", RewriterUtils.ResolveUrl(applicationPath, sendToUrl)); + } + action.DoReWrite = true; + action.RewriteUrl = sendToUrl; + return; } - action.DoReWrite = true; - action.RewriteUrl = sendToUrl; - return; - } #endif + } #endregion + #if !DNN71 // Find culture GetCulture(cacheCtrl, dicLocales, action, portalID); @@ -435,6 +455,30 @@ private static void RewriteUrl(HttpApplication app, Uri url, out string portalAl } + private static bool EnableBrowserLanguageInDefault(int portalId) + { + bool retValue = Null.NullBoolean; + try + { + var setting = Null.NullString; + PortalController.GetPortalSettingsDictionary(portalId).TryGetValue("EnableBrowserLanguage", out setting); + if (string.IsNullOrEmpty(setting)) + { + retValue = DotNetNuke.Entities.Host.Host.EnableBrowserLanguage; + } + else + { + retValue = (setting.StartsWith("Y", StringComparison.InvariantCultureIgnoreCase) || setting.ToUpperInvariant() == "TRUE"); + } + } + catch (Exception exc) + { + // Logger.Error(exc); + } + return retValue; + } + + private static bool IsSpecialPage(Uri Url, string PhysicalPath, string RawUrl, string WorkUrl) { if ( @@ -454,22 +498,22 @@ private static bool IsSpecialPage(Uri Url, string PhysicalPath, string RawUrl, s || Url.LocalPath.ToLower().EndsWith(".svc") ) return true; - /* - if ( !string.IsNullOrEmpty(PhysicalPath) && Directory.Exists(PhysicalPath) ) - { - return true; - } - */ - if (WorkUrl.ToLower().StartsWith("/desktopmodules/")) - { - return true; - } - //if (Url.LocalPath.ToLower().EndsWith(".aspx") && !Url.LocalPath.ToLower().EndsWith(Globals.glbDefaultPage.ToLower())) + /* + if ( !string.IsNullOrEmpty(PhysicalPath) && Directory.Exists(PhysicalPath) ) + { + return true; + } + */ + if (WorkUrl.ToLower().StartsWith("/desktopmodules/")) + { + return true; + } + //if (Url.LocalPath.ToLower().EndsWith(".aspx") && !Url.LocalPath.ToLower().EndsWith(Globals.glbDefaultPage.ToLower())) - if ((Directory.Exists(PhysicalPath) || File.Exists(PhysicalPath)) && !Url.LocalPath.ToLower().EndsWith(Globals.glbDefaultPage.ToLower())) - { - return true; - } + if ((Directory.Exists(PhysicalPath) || File.Exists(PhysicalPath)) && !Url.LocalPath.ToLower().EndsWith(Globals.glbDefaultPage.ToLower())) + { + return true; + } return false; } @@ -535,6 +579,7 @@ private static bool CheckTabIdRedirect(string ApplicationPath, Uri Url, PortalAl //if there is a match if (objMatch.Success) { + action.TabId = int.Parse(objMatch.Groups[1].Value); // if there is a rule for the tabid, the OpenUrlRewriter manage the rewriter otherwise the SiteUrls rules discard all processing var rule = cacheCtrl.GetRewriteTabRule(action.CultureCode, action.TabId); @@ -575,14 +620,30 @@ private static bool CheckTabIdRedirect(string ApplicationPath, Uri Url, PortalAl action.WorkUrl = RewriterUtils.ResolveUrl(ApplicationPath, "~" + langParms + "/" + rule.Url); } //action.RedirectUrl = action.HostPort + action.LocalPath; + action.DoRedirect = true; action.Raison += "+tabid present"; action.RedirectPage = rule.Url; RuleMatch = true; + } + // ~/Default.aspx?TabId=$1 } } + else if (cacheCtrl != null && action.QueryUrl.ToLower().Contains("tabid") && action.QueryUrl.ToLower().Contains("passwordreset")) // for performance + { + + string pattern = "^" + RewriterUtils.ResolveUrl(ApplicationPath, "[?&]TabId=(\\d+)(.*)") + "$"; + Match objMatch = Regex.Match(action.QueryUrl, pattern, RegexOptions.IgnoreCase); + //if there is a match + if (objMatch.Success) + { + + action.QueryUrl = Regex.Replace(action.QueryUrl, pattern, "$2", RegexOptions.IgnoreCase); + + } + } return RuleMatch; @@ -657,7 +718,7 @@ private static bool ProcessRedirect(HttpApplication app, string HttpMethod, Uri } RedirectTo += UrlRewiterSettings.Current().FileExtension; - redirect.QueryUrl= redirect.QueryUrl.TrimStart('?', '&'); + redirect.QueryUrl = redirect.QueryUrl.TrimStart('?', '&'); if (!string.IsNullOrEmpty(redirect.QueryUrl)) RedirectTo += (RedirectTo.Contains('?') ? "&" : "?") + redirect.QueryUrl; } @@ -1262,7 +1323,7 @@ private static PortalAliasInfo GetPortalAlias(Uri url, out string portalAlias) { PortalAliasInfo objPortalAlias = null; //string myAlias = Globals.GetDomainName(app.Request, true); - + #if DNN71 string myAlias = TestableGlobals.Instance.GetDomainName(url, true); #else @@ -1300,8 +1361,9 @@ private static void ProcessParameters(CacheController cacheCtrl, RewriterAction //split the value into an array based on "/" ( ie. /tabid/##/ ) string parameters = action.ModuleUrl.Replace("\\", "/").TrimStart('/'); var rule = cacheCtrl.GetModuleRule(action.CultureCode, action.TabId, parameters); - - if (rule == null) { + + if (rule == null) + { rule = cacheCtrl.GetCustomModuleRule(action.CultureCode, action.TabId, parameters); if (rule != null) { @@ -1323,7 +1385,7 @@ private static void ProcessParameters(CacheController cacheCtrl, RewriterAction return; } } - + if (rule != null) { if (rule.Action == UrlRuleAction.Redirect) @@ -1436,7 +1498,7 @@ private static void ProcessQuery(CacheController cacheCtrl, RewriterAction actio rule = cacheCtrl.GetCustomModuleRuleByParameters(action.CultureCode, action.TabId, parameters); if (rule != null) { - + if (rule.RemoveTab) { action.RedirectPage = ""; diff --git a/OpenUrlRewriter71.csproj b/OpenUrlRewriter71.csproj index 7f9c635..f243bf6 100644 --- a/OpenUrlRewriter71.csproj +++ b/OpenUrlRewriter71.csproj @@ -1,5 +1,14 @@  + + + 10.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + Debug @@ -13,7 +22,7 @@ Satrabel.OpenUrlRewriter - 3.5 + 4.0 v4.0 @@ -40,8 +49,10 @@ False ..\..\..\bin\DotNetNuke.dll - - + + False + ..\..\bin\DotNetNuke.Instrumentation.dll + @@ -250,8 +261,10 @@ - - + + + + diff --git a/Providers/SitemapProviders/OpenUrlRewriterSitemapProvider/OpenUrlRewriterSitemapProvider.cs b/Providers/SitemapProviders/OpenUrlRewriterSitemapProvider/OpenUrlRewriterSitemapProvider.cs index dd7f741..5ed5d12 100644 --- a/Providers/SitemapProviders/OpenUrlRewriterSitemapProvider/OpenUrlRewriterSitemapProvider.cs +++ b/Providers/SitemapProviders/OpenUrlRewriterSitemapProvider/OpenUrlRewriterSitemapProvider.cs @@ -112,7 +112,8 @@ public override List GetUrls(int portalId, PortalSettings ps, string { string[] pars = rule.Parameters.Split('&'); pageUrl = GetPageUrl(objTab, MultiLanguage ? loc.Code : null, pars); - pageUrl.Alternates.AddRange(GetAlternates(objTab.TabID, pars)); + // if module support ML + //pageUrl.Alternates.AddRange(GetAlternates(objTab.TabID, pars)); urls.Add(pageUrl); } } @@ -147,7 +148,7 @@ private List GetAlternates(int tabId, params string[] Addi }; - if (CanViewPage) + if (CanViewPage && !string.IsNullOrEmpty(alt.Href)) { alternates.Add(alt); } @@ -173,14 +174,10 @@ private List GetAlternates(int tabId, params string[] Addi private string newUrl(int tabId, string newLanguage, out bool CanViewPage, params string[] AdditionalParameters) { CanViewPage = true; - string Url; - + string Url = ""; Locale newLocale = LocaleController.Instance.GetLocale(newLanguage); - //Ensure that the current ActiveTab is the culture of the new language - bool islocalized = false; - TabInfo localizedTab = new TabController().GetTabByCulture(tabId, ps.PortalId, newLocale); if (localizedTab != null) { @@ -190,11 +187,9 @@ private string newUrl(int tabId, string newLanguage, out bool CanViewPage, param { CanViewPage = false; } - + Url = Globals.NavigateURL(localizedTab.TabID, localizedTab.IsSuperTab, ps, "", newLanguage, AdditionalParameters); } - - Url = Globals.NavigateURL(localizedTab.TabID, localizedTab.IsSuperTab, ps, "", newLanguage, AdditionalParameters); - + /* if (Url.ToLower().IndexOf(ps.PortalAlias.HTTPAlias.ToLower()) == -1) { // code to fix a bug in dnn5.1.2 for navigateurl @@ -208,7 +203,7 @@ private string newUrl(int tabId, string newLanguage, out bool CanViewPage, param Url = Globals.AddHTTP(ps.PortalAlias.HTTPAlias.ToLower()) + Url; } } - + */ return Url; } diff --git a/Providers/UrlRuleProviders/UrlBuilder.cs b/Providers/UrlRuleProviders/UrlBuilder.cs index 8ce45cd..02c9af6 100644 --- a/Providers/UrlRuleProviders/UrlBuilder.cs +++ b/Providers/UrlRuleProviders/UrlBuilder.cs @@ -42,10 +42,10 @@ namespace Satrabel.HttpModules.Provider { public class UrlBuilder { - - + DnnLogger logger = DnnLogger.GetClassLogger(typeof(UrlRuleConfiguration)); + public UrlBuilder() - { + { LoadProviders(); } @@ -63,27 +63,32 @@ public List BuildUrlMap(int PortalId) { isProviderEnabled = _provider.HostProvider; } - else - { - isProviderEnabled = bool.Parse(PortalController.GetPortalSetting(_provider.Name + "_Enabled", PortalId, "True")); + else + { + isProviderEnabled = bool.Parse(PortalController.GetPortalSetting(_provider.Name + "_Enabled", PortalId, "True")); } - if (isProviderEnabled ) + if (isProviderEnabled) { // Get all urls from provider - List urls = _provider.GetRules(PortalId); - if (urls != null) + try { - foreach (UrlRule url in urls) + List urls = _provider.GetRules(PortalId); + if (urls != null) { - allUrls.Add(url); + foreach (UrlRule url in urls) + { + allUrls.Add(url); + } + } + else + { + logger.Error("No urls for PortalId " + PortalId); } } - else + catch (Exception ex) { - DnnLogger logger = DnnLogger.GetClassLogger(typeof(UrlRuleConfiguration)); - logger.Error("No urls for PortalId " + PortalId); + logger.Error("Error on generating rules for " + _provider.Name, ex); } - } } return allUrls; @@ -92,7 +97,7 @@ public List BuildUrlMap(int PortalId) public string[] BuildCacheKeys() { var allCacheKeys = new List(); - + foreach (UrlRuleProvider _provider in Providers) { bool isProviderEnabled = true; //bool.Parse(PortalController.GetPortalSetting(_provider.Name + "_Enabled", PortalId, "True")); @@ -132,7 +137,7 @@ public string[] BuildCacheKeys(int PortalId) } return allCacheKeys.ToArray(); } - + #endregion @@ -169,8 +174,8 @@ private static void LoadProviders() //comp.Value.Name = comp.Key; //comp.Value.Description = comp.Value.Description; _providers.Add(comp.Value); - - + + } //'ProvidersHelper.InstantiateProviders(section.Providers, _providers, GetType(SiteMapProvider)) } diff --git a/Providers/UrlRuleProviders/UrlRule.cs b/Providers/UrlRuleProviders/UrlRule.cs index 977ec82..31288a8 100644 --- a/Providers/UrlRuleProviders/UrlRule.cs +++ b/Providers/UrlRuleProviders/UrlRule.cs @@ -73,7 +73,7 @@ public string ActionString private static string GenerateRegExp(string patern) { - return "^" + patern.Replace("[", "(?'").Replace("]", "'.*)").Replace("{", "(?'").Replace("}", "'\\d*)") + "$"; + return "^" + patern.Replace("+", "\\+").Replace("[", "(?'").Replace("]", "'.*)").Replace("{", "(?'").Replace("}", "'\\d*)") + "$"; } public bool IsMatch(string ModuleQueryString)