Fixing Accept header parsing so content types with leading/trailing spaces

are treated as spaceless.
Fixes #1684
This commit is contained in:
mark_story 2011-08-25 22:31:25 -04:00
parent ec79a09d27
commit 72ef310867
2 changed files with 5 additions and 1 deletions

View file

@ -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 file

@ -469,7 +469,10 @@ class RequestHandlerComponentTest extends CakeTestCase {
$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());
}
/**