mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Corrected port management in user login
--HG-- branch : dev
This commit is contained in:
@@ -4,28 +4,14 @@ using System.Web.Mvc;
|
||||
namespace Orchard.Mvc.Extensions {
|
||||
public static class ControllerExtensions {
|
||||
public static RedirectResult ReturnUrlRedirect(this Controller controller) {
|
||||
var request = controller.HttpContext.Request;
|
||||
Uri returnUrl = null;
|
||||
try {
|
||||
returnUrl = new Uri(request.QueryString["ReturnUrl"]);
|
||||
}
|
||||
catch {
|
||||
try {
|
||||
returnUrl =
|
||||
new Uri(string.Format("{0}://{1}{2}{3}", request.Url.Scheme, request.Url.Host,
|
||||
request.Url.Port != 80 ? ":" + request.Url.Port : "",
|
||||
request.QueryString["ReturnUrl"]));
|
||||
}
|
||||
catch { }
|
||||
string returnUrl = controller.Request.QueryString["ReturnUrl"];
|
||||
|
||||
// prevents phishing attacks by using only relative urls
|
||||
if(!returnUrl.StartsWith("/")) {
|
||||
return new RedirectResult("~/");
|
||||
}
|
||||
|
||||
if (returnUrl != null &&
|
||||
returnUrl.Scheme == request.Url.Scheme &&
|
||||
returnUrl.Port == request.Url.Port &&
|
||||
returnUrl.Host == request.Url.Host) {
|
||||
return new RedirectResult(returnUrl.ToString());
|
||||
}
|
||||
return new RedirectResult("~/");
|
||||
return new RedirectResult(returnUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user