Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ccb6dad

Browse filesBrowse files
committed
[HttpFoundation] fixed undefined offset for assoc arrays in HeaderBag
1 parent 1996c1f commit ccb6dad
Copy full SHA for ccb6dad

File tree

2 files changed

+9
-1
lines changed
Filter options

2 files changed

+9
-1
lines changed

‎src/Symfony/Component/HttpFoundation/HeaderBag.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/HeaderBag.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public function set($key, $values, $replace = true)
157157
{
158158
$key = strtr(strtolower($key), '_', '-');
159159

160-
$values = (array) $values;
160+
$values = array_values((array) $values);
161161

162162
if (true === $replace || !isset($this->headers[$key])) {
163163
$this->headers[$key] = $values;

‎src/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ public function testGet()
6868
$this->assertEquals( array('bar', 'bor'), $bag->get('foo', 'nope', false), '->get return all values as array');
6969
}
7070

71+
public function testSetAssociativeArray()
72+
{
73+
$bag = new HeaderBag();
74+
$bag->set('foo', array('bad-assoc-index' => 'value'));
75+
$this->assertSame('value', $bag->get('foo'));
76+
$this->assertEquals(array('value'), $bag->get('foo', 'nope', false), 'assoc indices of multi-valued headers are ignored');
77+
}
78+
7179
/**
7280
* @covers Symfony\Component\HttpFoundation\HeaderBag::contains
7381
*/

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.