Permalink
Browse files

[HttpFoundation] fixed undefined offset for assoc arrays in HeaderBag

  • Loading branch information...
1 parent 1996c1f commit ccb6dad09a215b0ad64fccff8eeb4e98e0de3e14 @Tobion Tobion committed Aug 17, 2012
View
2 src/Symfony/Component/HttpFoundation/HeaderBag.php
@@ -157,7 +157,7 @@ public function set($key, $values, $replace = true)
{
$key = strtr(strtolower($key), '_', '-');
- $values = (array) $values;
+ $values = array_values((array) $values);
if (true === $replace || !isset($this->headers[$key])) {
$this->headers[$key] = $values;
View
8 src/Symfony/Component/HttpFoundation/Tests/HeaderBagTest.php
@@ -68,6 +68,14 @@ public function testGet()
$this->assertEquals( array('bar', 'bor'), $bag->get('foo', 'nope', false), '->get return all values as array');
}
+ public function testSetAssociativeArray()
+ {
+ $bag = new HeaderBag();
+ $bag->set('foo', array('bad-assoc-index' => 'value'));
+ $this->assertSame('value', $bag->get('foo'));
+ $this->assertEquals(array('value'), $bag->get('foo', 'nope', false), 'assoc indices of multi-valued headers are ignored');
+ }
+
/**
* @covers Symfony\Component\HttpFoundation\HeaderBag::contains
*/

0 comments on commit ccb6dad

Please sign in to comment.