Skip to content

Commit 0b6726d

Browse files
Potential fix for code scanning alert no. 316: URL redirection from remote source (#640)
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 2ff6404 commit 0b6726d

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/Web/Grand.Web/Controllers/CommonController.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,11 @@ public virtual async Task<IActionResult> SetStore(
266266
}
267267

268268
//prevent open redirection attack
269-
if (!Url.IsLocalUrl(returnUrl))
270-
returnUrl = Url.RouteUrl("HomePage");
269+
var redirectUrl = Url.RouteUrl("HomePage");
270+
if (Url.IsLocalUrl(returnUrl))
271+
redirectUrl = returnUrl;
271272

272-
return Redirect(returnUrl);
273+
return Redirect(redirectUrl);
273274

274275
void SetStoreCookie(Domain.Stores.Store store)
275276
{

0 commit comments

Comments
 (0)