8000 [HttpKernel] Fixed RequestDataCollector handling of null header values. by gmoreira · Pull Request #20747 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpKernel] Fixed RequestDataCollector handling of null header values. #20747

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[HttpKernel] Fixed RequestDataCollector handling of null header values.
  • Loading branch information
Gabriel Moreira committed Dec 4, 2016
commit be38ba79ac7e0559da38f3d1136c7e760f902c07
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function collect(Request $request, Response $response, \Exception $except
continue;
}
if ('request_headers' === $key || 'response_headers' === $key) {
$value = array_map(function ($v) { return isset($v[1]) ? $v : $v[0]; }, $value);
$value = array_map(function ($v) { return isset($v[1]) ? $v : (isset($v[0]) ? $v[0] : null); }, $value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be even more defensive, I'd suggest: isset($v[0]) && !isset($v[1]) ? $v[0] : $v

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. With regards to the unit test however, would you omit this change to the unit test in order to not violate the current interface contract of the HeaderBag::set() method.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's green, let's do with for now.

}
if ('request_server' !== $key && 'request_cookies' !== $key) {
$this->data[$key] = array_map(array($this, 'cloneVar'), $value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ protected function createResponse()
$response = new Response();
$response->setStatusCode(200);
$response->headers->set('Content-Type', 'application/json');
$response->headers->set('X-Foo-Bar', null);
$response->headers->setCookie(new Cookie('foo', 'bar', 1, '/foo', 'localhost', true, true));
$response->headers->setCookie(new Cookie('bar', 'foo', new \DateTime('@946684800')));
$response->headers->setCookie(new Cookie('bazz', 'foo', '2000-12-12'));
Expand Down
0