8000 [HttpFoundation] fixed undefined offset for assoc arrays in HeaderBag · symfony/symfony@ccb6dad · GitHub
[go: up one dir, main page]

Skip to content

Commit ccb6dad

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

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Symfony/Component/HttpFoundation/HeaderBag.php

Lines 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

Lines 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