]> source.dussan.org Git - nextcloud-server.git/commitdiff
Fix absolute redirect 20401/head
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Fri, 10 Apr 2020 06:50:15 +0000 (08:50 +0200)
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Fri, 10 Apr 2020 06:58:54 +0000 (08:58 +0200)
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
core/Controller/LoginController.php
tests/Core/Controller/LoginControllerTest.php

index b3f7bb310ba05caf46b9a5b031412be4e30482a2..60fd22bd0d1e83c45490f5d4a61e40f91068fd63 100644 (file)
@@ -260,7 +260,7 @@ class LoginController extends Controller {
 
        private function generateRedirect(?string $redirectUrl): RedirectResponse {
                if ($redirectUrl !== null && $this->userSession->isLoggedIn()) {
-                       $location = $this->urlGenerator->getAbsoluteURL(urldecode($redirectUrl));
+                       $location = $this->urlGenerator->getAbsoluteURL($redirectUrl);
                        // Deny the redirect if the URL contains a @
                        // This prevents unvalidated redirects like ?redirect_url=:user@domain.com
                        if (strpos($location, '@') === false) {
index 80be53ed26d12a4f967d449be69882b69abc87fa..e9d4a89aa7d78923b2c87e554f7d3524fd43072b 100644 (file)
@@ -509,7 +509,7 @@ class LoginControllerTest extends TestCase {
                        ->method('getUID')
                        ->willReturn('jane');
                $password = 'secret';
-               $originalUrl = 'another%20url';
+               $originalUrl = 'another url';
                $redirectUrl = 'http://localhost/another url';
 
                $this->request
@@ -551,7 +551,7 @@ class LoginControllerTest extends TestCase {
                        $this->request,
                        $user,
                        $password,
-                       '%2Fapps%2Fmail'
+                       '/apps/mail'
                );
                $loginResult = LoginResult::success($loginData);
                $this->chain->expects($this->once())
@@ -563,11 +563,11 @@ class LoginControllerTest extends TestCase {
                        ->willReturn(true);
                $this->urlGenerator->expects($this->once())
                        ->method('getAbsoluteURL')
-                       ->with(urldecode('/apps/mail'))
+                       ->with('/apps/mail')
                        ->willReturn($redirectUrl);
                $expected = new \OCP\AppFramework\Http\RedirectResponse($redirectUrl);
 
-               $response = $this->loginController->tryLogin($user, $password, '%2Fapps%2Fmail');
+               $response = $this->loginController->tryLogin($user, $password, '/apps/mail');
 
                $this->assertEquals($expected, $response);
        }