mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Don't map text/plain to csv. Backport from 3.0. Refs #1696
Jquery sets accepts header similar to "text/plain, */*; q=0.01" by default for xhr requests. Due to this RequestHandler used to set extension to csv thereby causing View class to look for views under non-existent csv folders.
This commit is contained in:
parent
b9e617997e
commit
94fbc6e5f2
2 changed files with 15 additions and 1 deletions
|
@ -96,7 +96,7 @@ class CakeResponse {
|
||||||
'cpio' => 'application/x-cpio',
|
'cpio' => 'application/x-cpio',
|
||||||
'cpt' => 'application/mac-compactpro',
|
'cpt' => 'application/mac-compactpro',
|
||||||
'csh' => 'application/x-csh',
|
'csh' => 'application/x-csh',
|
||||||
'csv' => array('text/csv', 'application/vnd.ms-excel', 'text/plain'),
|
'csv' => array('text/csv', 'application/vnd.ms-excel'),
|
||||||
'dcr' => 'application/x-director',
|
'dcr' => 'application/x-director',
|
||||||
'dir' => 'application/x-director',
|
'dir' => 'application/x-director',
|
||||||
'dms' => 'application/octet-stream',
|
'dms' => 'application/octet-stream',
|
||||||
|
|
|
@ -197,6 +197,20 @@ class RequestHandlerComponentTest extends CakeTestCase {
|
||||||
$this->assertEquals('json', $this->RequestHandler->ext);
|
$this->assertEquals('json', $this->RequestHandler->ext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test that RequestHandler does not set extension to csv for text/plain mimetype
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testInitializeContentTypeWithjQueryTextPlainAccept() {
|
||||||
|
$_SERVER['HTTP_ACCEPT'] = 'text/plain, */*; q=0.01';
|
||||||
|
$this->assertNull($this->RequestHandler->ext);
|
||||||
|
Router::parseExtensions('csv');
|
||||||
|
|
||||||
|
$this->RequestHandler->initialize($this->Controller);
|
||||||
|
$this->assertNull($this->RequestHandler->ext);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that RequestHandler sets $this->ext when jQuery sends its wonky-ish headers
|
* Test that RequestHandler sets $this->ext when jQuery sends its wonky-ish headers
|
||||||
* and the application is configured to handle multiple extensions
|
* and the application is configured to handle multiple extensions
|
||||||
|
|
Loading…
Reference in a new issue