-
Notifications
You must be signed in to change notification settings - Fork 653
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] PSR-7 responses return header using getHeader()
The base PSR-7 implementation of the Response object does not sanitize the headers properly when handing them in as an array, thus, it is stored wrong in the Response object. Resolves: #84853 Releases: master, 8.7 Change-Id: I7571f1438bc602bcae9367b82f99946ed22d8308 Reviewed-on: https://review.typo3.org/56093 Tested-by: TYPO3com <no-reply@typo3.com> Reviewed-by: Andreas Wolf <andreas.wolf@typo3.org> Tested-by: Andreas Wolf <andreas.wolf@typo3.org> Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de> Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch> Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
- Loading branch information
Showing
3 changed files
with
118 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
104 changes: 104 additions & 0 deletions
104
typo3/sysext/core/Tests/Unit/Http/RedirectResponseTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
namespace TYPO3\CMS\Core\Tests\Unit\Http; | ||
|
||
/* | ||
* This file is part of the TYPO3 CMS project. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
use TYPO3\CMS\Core\Http\RedirectResponse; | ||
use TYPO3\TestingFramework\Core\Unit\UnitTestCase; | ||
|
||
/** | ||
* Test case | ||
*/ | ||
class RedirectResponseTest extends UnitTestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function getHeadersReturnsLocationUrlSetByConstructorArgument() | ||
{ | ||
$subject = new RedirectResponse('theRedirectUrl'); | ||
$expected = [ | ||
'location' => [ | ||
0 => 'theRedirectUrl', | ||
] | ||
]; | ||
$this->assertSame($expected, $subject->getHeaders()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getHeaderReturnsLocationUrlSetByConstructorArgument() | ||
{ | ||
$subject = new RedirectResponse('theRedirectUrl'); | ||
$expected = [ | ||
0 => 'theRedirectUrl', | ||
]; | ||
$this->assertSame($expected, $subject->getHeader('location')); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getHeadersReturnsHeaderSetByConstructorArgument() | ||
{ | ||
$input = [ | ||
'camelCasedHeaderName' => 'aHeaderValue', | ||
'lowercasedheadername' => 'anotherHeaderValue', | ||
]; | ||
$expected = [ | ||
'camelCasedHeaderName' => [ | ||
0 => 'aHeaderValue', | ||
], | ||
'lowercasedheadername' => [ | ||
0 => 'anotherHeaderValue', | ||
], | ||
'location' => [ | ||
0 => 'url' | ||
], | ||
]; | ||
$subject = new RedirectResponse('url', 302, $input); | ||
$this->assertSame($expected, $subject->getHeaders()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getHeaderReturnsHeaderSetByConstructorArgument() | ||
{ | ||
$input = [ | ||
'lowercasedheadername' => 'anotherHeaderValue', | ||
]; | ||
$expected = [ | ||
0 => 'anotherHeaderValue', | ||
]; | ||
$subject = new RedirectResponse('url', 302, $input); | ||
$this->assertSame($expected, $subject->getHeader('lowercasedheadername')); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function getHeaderReturnsHeaderSetByConstructorArgumentLowerCased() | ||
{ | ||
$input = [ | ||
'camelCasedHeaderName' => 'aHeaderValue', | ||
]; | ||
$expected = [ | ||
0 => 'aHeaderValue', | ||
]; | ||
$subject = new RedirectResponse('url', 302, $input); | ||
$this->assertSame($expected, $subject->getHeader('camelCasedHeaderName')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters