Browse Source

Merge pull request #2066 from nextcloud/fix-redirect-double-encoding

do not double encode the redirect url
pull/2412/head
Morris Jobke 9 years ago
committed by GitHub
parent
commit
d86b29b42b
  1. 2
      lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php
  2. 2
      lib/private/legacy/util.php
  3. 12
      tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php

2
lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php

@ -250,7 +250,7 @@ class SecurityMiddleware extends Middleware {
$url = $this->urlGenerator->linkToRoute( $url = $this->urlGenerator->linkToRoute(
'core.login.showLoginForm', 'core.login.showLoginForm',
[ [
'redirect_url' => urlencode($this->request->server['REQUEST_URI']),
'redirect_url' => $this->request->server['REQUEST_URI'],
] ]
); );
$response = new RedirectResponse($url); $response = new RedirectResponse($url);

2
lib/private/legacy/util.php

@ -975,7 +975,7 @@ class OC_Util {
header('Location: ' . \OC::$server->getURLGenerator()->linkToRoute( header('Location: ' . \OC::$server->getURLGenerator()->linkToRoute(
'core.login.showLoginForm', 'core.login.showLoginForm',
[ [
'redirect_url' => urlencode(\OC::$server->getRequest()->getRequestUri()),
'redirect_url' => \OC::$server->getRequest()->getRequestUri(),
] ]
) )
); );

12
tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php

@ -459,7 +459,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
'server' => 'server' =>
[ [
'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'REQUEST_URI' => 'owncloud/index.php/apps/specialapp'
'REQUEST_URI' => 'nextcloud/index.php/apps/specialapp'
] ]
], ],
$this->createMock(ISecureRandom::class), $this->createMock(ISecureRandom::class),
@ -472,10 +472,10 @@ class SecurityMiddlewareTest extends \Test\TestCase {
->with( ->with(
'core.login.showLoginForm', 'core.login.showLoginForm',
[ [
'redirect_url' => 'owncloud%2Findex.php%2Fapps%2Fspecialapp',
'redirect_url' => 'nextcloud/index.php/apps/specialapp',
] ]
) )
->will($this->returnValue('http://localhost/index.php/login?redirect_url=owncloud%2Findex.php%2Fapps%2Fspecialapp'));
->will($this->returnValue('http://localhost/nextcloud/index.php/login?redirect_url=nextcloud/index.php/apps/specialapp'));
$this->logger $this->logger
->expects($this->once()) ->expects($this->once())
->method('debug') ->method('debug')
@ -485,7 +485,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
'test', 'test',
new NotLoggedInException() new NotLoggedInException()
); );
$expected = new RedirectResponse('http://localhost/index.php/login?redirect_url=owncloud%2Findex.php%2Fapps%2Fspecialapp');
$expected = new RedirectResponse('http://localhost/nextcloud/index.php/login?redirect_url=nextcloud/index.php/apps/specialapp');
$this->assertEquals($expected , $response); $this->assertEquals($expected , $response);
} }
@ -494,7 +494,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
[ [
'server' => [ 'server' => [
'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'REQUEST_URI' => 'owncloud/index.php/apps/specialapp',
'REQUEST_URI' => 'nextcloud/index.php/apps/specialapp',
], ],
], ],
$this->createMock(ISecureRandom::class), $this->createMock(ISecureRandom::class),
@ -540,7 +540,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
'server' => 'server' =>
[ [
'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'REQUEST_URI' => 'owncloud/index.php/apps/specialapp'
'REQUEST_URI' => 'nextcloud/index.php/apps/specialapp'
] ]
], ],
$this->createMock(ISecureRandom::class), $this->createMock(ISecureRandom::class),

Loading…
Cancel
Save