Skip to content

Commit

Permalink
Merge pull request #9108 from cakephp/issue-9106
Browse files Browse the repository at this point in the history
Don't split strings headers that lack a ':'.
  • Loading branch information
markstory committed Jul 16, 2016
2 parents 7763e5d + 4e1b601 commit 876b508
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Network/CakeResponse.php
Expand Up @@ -577,7 +577,7 @@ public function header($header = null, $value = null) {
if (is_numeric($header)) {
list($header, $value) = array($value, null);
}
if ($value === null) {
if ($value === null && strpos($header, ':') !== false) {
list($header, $value) = explode(':', $header, 2);
}
$this->_headers[$header] = is_array($value) ? array_map('trim', $value) : trim($value);
Expand Down
6 changes: 5 additions & 1 deletion lib/Cake/Test/Case/Network/CakeResponseTest.php
Expand Up @@ -164,11 +164,15 @@ public function testHeader() {
$headers += array('Location' => 'http://example.com');
$this->assertEquals($headers, $response->header());

//Headers with the same name are overwritten
// Headers with the same name are overwritten
$response->header('Location', 'http://example2.com');
$headers = array('Location' => 'http://example2.com');
$this->assertEquals($headers, $response->header());

$response->header('Date', null);
$headers += array('Date' => null);
$this->assertEquals($headers, $response->header());

$response->header(array('WWW-Authenticate' => 'Negotiate'));
$headers += array('WWW-Authenticate' => 'Negotiate');
$this->assertEquals($headers, $response->header());
Expand Down

0 comments on commit 876b508

Please sign in to comment.