Skip to content

Commit

Permalink
#6643 NopRedirectResultExecutor incorrect path when virtual directory…
Browse files Browse the repository at this point in the history
… is used
  • Loading branch information
kirilchik committed Apr 7, 2023
1 parent 440348e commit 2fcd4c5
Showing 1 changed file with 7 additions and 1 deletion.
Expand Up @@ -59,7 +59,13 @@ public override Task ExecuteAsync(ActionContext context, RedirectResult result)
var urlHelper = result.UrlHelper ?? _urlHelperFactory.GetUrlHelper(_actionContextAccessor.ActionContext);
var isLocalUrl = urlHelper.IsLocalUrl(url);

var uri = new Uri(isLocalUrl ? $"{_webHelper.GetStoreLocation().TrimEnd('/')}{url}" : url, UriKind.Absolute);
var uriStr = url;
if (isLocalUrl)
{
var pathBase = context.HttpContext.Request.PathBase;
uriStr = $"{_webHelper.GetStoreLocation().TrimEnd('/')}{(url.StartsWith(pathBase) && !string.IsNullOrEmpty(pathBase) ? url.Replace(pathBase, "") : url)}";
}
var uri = new Uri(uriStr, UriKind.Absolute);

//Allowlist redirect URI schemes to http and https
if ((uri.Scheme == Uri.UriSchemeHttp || uri.Scheme == Uri.UriSchemeHttps) && urlHelper.IsLocalUrl(uri.AbsolutePath))
Expand Down

0 comments on commit 2fcd4c5

Please sign in to comment.