/// <summary> /// rewrite CDN urls from /path/to/file!cf!a=1!b=2.ext to original form /path/to/file.ext?a=1&b=2 /// </summary> /// <param name="args"></param> public override void Process(PreprocessRequestArgs args) { Assert.ArgumentNotNull(args, "args"); // rehydrate original url string fullPath = Sitecore.Context.RawUrl; var url = new UrlString(fullPath); // if this item is a minifiable css or js // rewrite for ~/minify handler if (CDNSettings.Enabled && CDNSettings.MinifyEnabled && url["min"] == "1" && !url.Path.StartsWith(Settings.Media.DefaultMediaPrefix) && (url.Path.EndsWith(".css") || url.Path.EndsWith(".js"))) { args.Context.Items["MinifyPath"] = fullPath; // set this for the Minifier handler args.Context.RewritePath("/~/minify" + url.Path, string.Empty, url.Query); // rewrite with ~/minify to trigger custom handler } // NOTE: DOREL CHANGE: Commented to make WCF services (*.svc) workable // else // { // args.Context.RewritePath(url.Path, string.Empty, url.Query); // rewrite proper url // } }
public override void Process(PreprocessRequestArgs args) { if (!_sitesFilter.Contains(Sitecore.Context.Site.Name)) { SiteProcess(args); } }
public override void Process(PreprocessRequestArgs args) { if (!_sitesFilter.Contains(Sitecore.Context.Site.Name)) { SiteProcess(args); } }
public override void Process(PreprocessRequestArgs args) { if (args.Context.Request.RawUrl.Contains("CaptchaImage.axd")) { var handler = (new MSCaptcha.CaptchaImageHandler()) as IHttpHandler; handler.ProcessRequest(args.Context); } }
public override void Process(PreprocessRequestArgs args) { if (args.Context.Request.RawUrl.Contains("CaptchaImage.axd")) { var handler = (new MSCaptcha.CaptchaImageHandler()) as IHttpHandler; handler.ProcessRequest(args.Context); } }
/// <summary> /// Processes the specified arguments. /// </summary> /// <param name="args">The arguments.</param> public override void Process(PreprocessRequestArgs args) { ExecuteWithoutException(() => {; if (args?.Context?.Request.Path == null || !args.Context.Request.Path.StartsWith(ModuleInfo.RoutePrefix, false, CultureInfo.InvariantCulture)) { return; } ExecuteRewrite(new HttpContextWrapper(args.Context), ModuleInfo.RoutePrefix.TrimEnd('/')); }); }
/// <summary>Processes the specified arguments.</summary> /// <param name="args">The arguments.</param> public override void Process(PreprocessRequestArgs args) { Assert.ArgumentNotNull((object)args, "args"); Language language = ExtractLanguage(args.Context.Request); if (language == (Language)null) { //if url doesn't contain language name, we will set the default language language = Sitecore.Globalization.Language.Parse("en"); } Context.Language = language; Context.Data.FilePathLanguage = language; }
public override void Process(PreprocessRequestArgs args) { var context = args.HttpContext; if (context.Request.HttpMethod != HttpMethod.Get.Method && context.Request.HttpMethod != HttpMethod.Head.Method) { return; } if (!(context.Request.Path.Equals(_livenessPath, StringComparison.OrdinalIgnoreCase) || context.Request.Path.Equals(_readinessPath, StringComparison.OrdinalIgnoreCase))) { return; } args.AbortPipeline(); context.Items["SitecoreOn"] = false; var pipelineArgs = new HealthCheckPipelineArgs(); if (context.Request.Path.Equals(_livenessPath, StringComparison.OrdinalIgnoreCase)) { CorePipeline.Run(LivenessHealthCheckPipelineName, pipelineArgs, true); } else if (context.Request.Path.Equals(_readinessPath, StringComparison.OrdinalIgnoreCase)) { CorePipeline.Run(ReadinessHealthCheckPipelineName, pipelineArgs, true); } context.Response.ContentType = "text/plain"; foreach (var message in pipelineArgs.GetAllMessages()) { context.Response.Write(message + Environment.NewLine); } if (pipelineArgs.IsSuccess()) { context.Response.StatusCode = 200; } else { context.Response.TrySkipIisCustomErrors = true; context.Response.StatusCode = 503; } context.ApplicationInstance.CompleteRequest(); }
public override void Process(PreprocessRequestArgs args) { try { new SuppressFormValidation().Process(args); } catch (HttpRequestValidationException) { // NOTE [ILs] Only URLs with "login" are considered safe for special character input. (Required for WsFed) string rawUrl = args?.Context.Request.RawUrl ?? string.Empty; if (!rawUrl.Contains("login")) { throw; } } }
/// <summary> /// Adds a session variable when using AMP and removes the token when not /// </summary> /// <param name="args">the PreprocessRequestArgs</param> public override void Process(PreprocessRequestArgs args) { Assert.ArgumentNotNull((object)args, nameof(args)); // remove initial check (expired = true) args.HttpContext.SetAmpCookie(true); // check if the url is requested with the /amp postfix if (args.HttpContext.UseAmp()) { // set cookie for future usage args.HttpContext.SetAmpCookie(); // rewrite url to get original item args.HttpContext.RewriteUrl(); } }
public override void Process(PreprocessRequestArgs args) { Assert.ArgumentNotNull(args, "args"); try { new SuppressFormValidation().Process(args); } catch (HttpRequestValidationException) { string rawUrl = args.Context.Request.RawUrl; if (!rawUrl.Contains("sample item") && !rawUrl.Contains("secure") && !rawUrl.Contains("login")) { throw; } } }
public override void Process(PreprocessRequestArgs args) { Assert.ArgumentNotNull(args, "args"); try { new SuppressFormValidation().Process(args); } catch (HttpRequestValidationException) { string rawUrl = args.Context.Request.RawUrl; if (!rawUrl.StartsWith("/sitecore/shell/", System.StringComparison.InvariantCultureIgnoreCase) && !rawUrl.StartsWith("/sitecore/admin/", System.StringComparison.InvariantCultureIgnoreCase) && !rawUrl.StartsWith("/-/speak/request/", System.StringComparison.InvariantCultureIgnoreCase)) { throw; } } }
public override void Process(PreprocessRequestArgs args) { Assert.ArgumentNotNull(args, "args"); if (!Settings.Languages.AlwaysStripLanguage) { return; } Language language = ExtractLanguage(args.Context.Request); if (language == null) { return; } Context.Language = language; Context.Data.FilePathLanguage = language; RewriteUrl(args.Context, language); Tracer.Info(string.Format("Language changed to \"{0}\" as request url contains language embedded in the file path.", language.Name)); }
/// <summary> /// rewrite CDN urls from /path/to/file!cf!a=1!b=2.ext to original form /path/to/file.ext?a=1&b=2 /// </summary> /// <param name="args"></param> public override void Process(PreprocessRequestArgs args) { Assert.ArgumentNotNull(args, "args"); // rehydrate original url string fullPath = Sitecore.Context.RawUrl; UrlString url = new UrlString(fullPath); // if this item is a minifiable css or js // rewrite for ~/minify handler if (CDNSettings.Enabled && CDNSettings.MinifyEnabled && url["min"] == "1" && !url.Path.StartsWith(Settings.Media.DefaultMediaPrefix) && (url.Path.EndsWith(".css") || url.Path.EndsWith(".js"))) { args.Context.Items["MinifyPath"] = fullPath; // set this for the Minifier handler args.Context.RewritePath("/~/minify" + url.Path, "", url.Query); // rewrite with ~/minify to trigger custom handler } else { args.Context.RewritePath(url.Path, "", url.Query); // rewrite proper url } }
public override void Process(PreprocessRequestArgs args) { var fiftyOneDegreesService = new FiftyOneDegreesServiceFactory().Create(new HttpContextWrapper(args.Context)); fiftyOneDegreesService.SetBrowserCapabilities(); }
public override void Process(PreprocessRequestArgs args) { Sitecore.Diagnostics.Assert.ArgumentNotNull(args, "args"); args.AbortPipeline(); return; }
public override void Process(PreprocessRequestArgs arguments) { Assert.ArgumentNotNull(arguments, "arguments"); try { var url = TypeResolver.Resolve <IObsoletor>().GetRequestUrl(arguments); var localPath = url.LocalPath; if (localPath.StartsWith("/-/script/v1", StringComparison.OrdinalIgnoreCase)) { var sourceArray = url.LocalPath.TrimStart('/').Split('/'); if (sourceArray.Length < 3) { return; } var length = sourceArray.Length - 3; var destinationArray = new string[length]; Array.Copy(sourceArray, 3, destinationArray, 0, length); var scriptPath = $"/{string.Join("/", destinationArray)}"; var query = url.Query.TrimStart('?'); query += $"{(string.IsNullOrEmpty(query) ? "?" : "&")}script={scriptPath}&apiVersion=1"; WebUtil.RewriteUrl( new UrlString { Path = "/sitecore modules/PowerShell/Services/RemoteScriptCall.ashx", Query = query }.ToString()); } if (localPath.StartsWith("/-/script/v2", StringComparison.OrdinalIgnoreCase) || localPath.StartsWith("/-/script/media", StringComparison.OrdinalIgnoreCase) || localPath.StartsWith("/-/script/file", StringComparison.OrdinalIgnoreCase) || localPath.StartsWith("/-/script/handle", StringComparison.OrdinalIgnoreCase) || localPath.StartsWith("/-/script/script", StringComparison.OrdinalIgnoreCase) ) { var sourceArray = url.LocalPath.TrimStart('/').Split(new [] { "/" }, StringSplitOptions.RemoveEmptyEntries); if (sourceArray.Length < 3) { return; } if (sourceArray.Length == 3) { Array.Resize(ref sourceArray, 4); sourceArray[3] = ""; } var apiVersion = sourceArray[2].Is("v2") ? "2": sourceArray[2]; var length = sourceArray.Length - 4; var destinationArray = new string[length]; var origin = sourceArray[3].ToLowerInvariant(); var database = apiVersion.Is("file") || apiVersion.Is("handle") ? string.Empty : origin; Array.Copy(sourceArray, 4, destinationArray, 0, length); var scriptPath = $"/{string.Join("/", destinationArray)}"; var query = url.Query.TrimStart('?'); query += $"{(string.IsNullOrEmpty(query) ? "" : "&")}script={scriptPath}&sc_database={database}&scriptDb={origin}&apiVersion={apiVersion}"; WebUtil.RewriteUrl( new UrlString { Path = "/sitecore modules/PowerShell/Services/RemoteScriptCall.ashx", Query = query }.ToString()); } } catch (Exception exception) { PowerShellLog.Error("Error during the SPE API call", exception); } }
public override void Process(PreprocessRequestArgs arguments) { Assert.ArgumentNotNull(arguments, "arguments"); try { Assert.ArgumentNotNull(arguments.Context, "context"); var url = arguments.Context.Request.Url; var localPath = url.LocalPath; if (localPath.StartsWith("/Console/", StringComparison.OrdinalIgnoreCase)) { // this bit is for compatibility of solutions integrating with SPE 2.x services in mind WebUtil.RewriteUrl( new UrlString { Path = localPath.ToLowerInvariant().Replace("/console/", "/sitecore modules/PowerShell/"), Query = url.Query }.ToString()); } if (localPath.StartsWith("/-/script/v1", StringComparison.OrdinalIgnoreCase)) { var sourceArray = url.LocalPath.TrimStart('/').Split('/'); if (sourceArray.Length < 3) { return; } var length = sourceArray.Length - 3; var destinationArray = new string[length]; Array.Copy(sourceArray, 3, destinationArray, 0, length); var scriptPath = string.Format("/{0}", string.Join("/", destinationArray)); var query = url.Query.TrimStart('?'); query += string.Format("{0}script={1}&apiVersion=1", string.IsNullOrEmpty(query) ? "?" : "&", scriptPath); WebUtil.RewriteUrl( new UrlString { Path = "/sitecore modules/PowerShell/Services/RemoteScriptCall.ashx", Query = query }.ToString()); } if (localPath.StartsWith("/-/script/v2", StringComparison.OrdinalIgnoreCase) || localPath.StartsWith("/-/script/media", StringComparison.OrdinalIgnoreCase) || localPath.StartsWith("/-/script/file", StringComparison.OrdinalIgnoreCase) ) { var sourceArray = url.LocalPath.TrimStart('/').Split('/'); if (sourceArray.Length < 4) { return; } string apiVersion = sourceArray[2].Is("v2") ? "2": sourceArray[2]; var length = sourceArray.Length - 4; var destinationArray = new string[length]; var origin = sourceArray[3].ToLowerInvariant(); string database = apiVersion.Is("file") ? string.Empty : origin; Array.Copy(sourceArray, 4, destinationArray, 0, length); var scriptPath = string.Format("/{0}", string.Join("/", destinationArray)); var query = url.Query.TrimStart('?'); query += string.Format("{0}script={1}&sc_database={2}&scriptDb={3}&apiVersion={4}", string.IsNullOrEmpty(query) ? "" : "&", scriptPath, database, origin, apiVersion); WebUtil.RewriteUrl( new UrlString { Path = "/sitecore modules/PowerShell/Services/RemoteScriptCall.ashx", Query = query }.ToString()); } } catch (Exception exception) { Log.Error("Error during the SPE API call", exception); } }
public abstract void SiteProcess(PreprocessRequestArgs args);
public override void Process(PreprocessRequestArgs arguments) { Assert.ArgumentNotNull(arguments, "arguments"); try { Assert.ArgumentNotNull(arguments.Context, "context"); var url = arguments.Context.Request.Url; var localPath = url.LocalPath; //Compatibility with 2.x services location now removed - uncomment the following to restore // Issue #511 /* * if (localPath.StartsWith("/Console/", StringComparison.OrdinalIgnoreCase)) * { * // this bit is for compatibility of solutions integrating with SPE 2.x services in mind * WebUtil.RewriteUrl( * new UrlString * { * Path = localPath.ToLowerInvariant().Replace("/console/", "/sitecore modules/PowerShell/"), * Query = url.Query * }.ToString()); * } */ if (localPath.StartsWith("/-/script/v1", StringComparison.OrdinalIgnoreCase)) { var sourceArray = url.LocalPath.TrimStart('/').Split('/'); if (sourceArray.Length < 3) { return; } var length = sourceArray.Length - 3; var destinationArray = new string[length]; Array.Copy(sourceArray, 3, destinationArray, 0, length); var scriptPath = string.Format("/{0}", string.Join("/", destinationArray)); var query = url.Query.TrimStart('?'); query += string.Format("{0}script={1}&apiVersion=1", string.IsNullOrEmpty(query) ? "?" : "&", scriptPath); WebUtil.RewriteUrl( new UrlString { Path = "/sitecore modules/PowerShell/Services/RemoteScriptCall.ashx", Query = query }.ToString()); } if (localPath.StartsWith("/-/script/v2", StringComparison.OrdinalIgnoreCase) || localPath.StartsWith("/-/script/media", StringComparison.OrdinalIgnoreCase) || localPath.StartsWith("/-/script/file", StringComparison.OrdinalIgnoreCase) || localPath.StartsWith("/-/script/handle", StringComparison.OrdinalIgnoreCase) ) { var sourceArray = url.LocalPath.TrimStart('/').Split('/'); if (sourceArray.Length < 4) { return; } string apiVersion = sourceArray[2].Is("v2") ? "2": sourceArray[2]; var length = sourceArray.Length - 4; var destinationArray = new string[length]; var origin = sourceArray[3].ToLowerInvariant(); string database = apiVersion.Is("file") || apiVersion.Is("handle") ? string.Empty : origin; Array.Copy(sourceArray, 4, destinationArray, 0, length); var scriptPath = string.Format("/{0}", string.Join("/", destinationArray)); var query = url.Query.TrimStart('?'); query += string.Format("{0}script={1}&sc_database={2}&scriptDb={3}&apiVersion={4}", string.IsNullOrEmpty(query) ? "" : "&", scriptPath, database, origin, apiVersion); WebUtil.RewriteUrl( new UrlString { Path = "/sitecore modules/PowerShell/Services/RemoteScriptCall.ashx", Query = query }.ToString()); } } catch (Exception exception) { PowerShellLog.Error("Error during the SPE API call", exception); } }
public Uri GetRequestUrl(PreprocessRequestArgs args) { return(args.HttpContext.Request.Url); }
public abstract void SiteProcess(PreprocessRequestArgs args);