Browse files

Fixing Accept header parsing so content types with leading/trailing s…

…paces

are treated as spaceless.
Fixes #1684
  • Loading branch information...
1 parent ec79a09 commit 72ef310867c208a80a414114eba56befe3511055 @markstory markstory committed Aug 26, 2011
View
1 cake/libs/controller/components/request_handler.php
@@ -176,6 +176,7 @@ class RequestHandlerComponent extends Object {
*/
function __construct() {
$this->__acceptTypes = explode(',', env('HTTP_ACCEPT'));
+ $this->__acceptTypes = array_map('trim', $this->__acceptTypes);
foreach ($this->__acceptTypes as $i => $type) {
if (strpos($type, ';')) {
View
5 cake/tests/cases/libs/controller/components/request_handler.test.php
@@ -469,7 +469,10 @@ function testRequestContentTypes() {
$this->_init();
$this->assertTrue($this->RequestHandler->isWap());
- $_SERVER['HTTP_ACCEPT'] = 'application/rss+xml,text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,*/*';
+ $_SERVER['HTTP_ACCEPT'] = 'application/rss+xml , text/xml, application/xml,application/xhtml+xml';
+ $this->_init();
+ $this->assertFalse($this->RequestHandler->isAtom());
+ $this->assertTrue($this->RequestHandler->isRSS());
}
/**

0 comments on commit 72ef310

Please sign in to comment.