Skip to content
Permalink
Browse files

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.
  • Loading branch information...
dy-dx committed Jul 7, 2015
1 parent b9e6179 commit 94fbc6e5f28fd09ab1ebdbcc6d1382844de13c65
@@ -96,7 +96,7 @@ class CakeResponse {
'cpio' => 'application/x-cpio',
'cpt' => 'application/mac-compactpro',
'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',
'dir' => 'application/x-director',
'dms' => 'application/octet-stream',
@@ -197,6 +197,20 @@ public function testInitializeContentTypeWithjQueryAccept() {
$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
* and the application is configured to handle multiple extensions

0 comments on commit 94fbc6e

Please sign in to comment.
You can’t perform that action at this time.