mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixed issue when using multiple extensions in Router::parseExtensions() could result in undefined index notice by RequestHandlerComponent.
This commit is contained in:
parent
fb4a003522
commit
646b8f1aa0
2 changed files with 16 additions and 1 deletions
|
@ -140,7 +140,7 @@ class RequestHandlerComponent extends Component {
|
|||
$preferredTypes = $this->mapType($preferred);
|
||||
$similarTypes = array_intersect($extensions, $preferredTypes);
|
||||
if (count($similarTypes) === 1 && !in_array('html', $preferredTypes)) {
|
||||
$this->ext = $similarTypes[0];
|
||||
$this->ext = array_shift($similarTypes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -193,6 +193,21 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
|||
$this->assertEquals('json', $this->RequestHandler->ext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that RequestHandler sets $this->ext when jQuery sends its wonky-ish headers
|
||||
* and the application is configured to handle multiplate extensions
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testInitializeContentTypeWithjQueryAcceptAndMultiplesExtensions() {
|
||||
$_SERVER['HTTP_ACCEPT'] = 'application/json, text/javascript, */*; q=0.01';
|
||||
$this->assertNull($this->RequestHandler->ext);
|
||||
Router::parseExtensions('rss', 'json');
|
||||
|
||||
$this->RequestHandler->initialize($this->Controller);
|
||||
$this->assertEquals('json', $this->RequestHandler->ext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that RequestHandler does not set $this->ext when multple accepts are sent.
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue