1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-02-25 02:22:57 +01:00

Fixes todo on splitting headers by ';'

This commit is contained in:
Ben Longden 2013-06-28 17:29:14 +01:00
parent c43b822e02
commit 13178c36b0
2 changed files with 4 additions and 5 deletions

View File

@ -124,7 +124,6 @@ class Header implements HeaderInterface
/**
* {@inheritdoc}
* @todo Do not split semicolons when enclosed in quotes (e.g. foo="baz;bar")
*/
public function parseParams()
{
@ -135,11 +134,10 @@ class Header implements HeaderInterface
foreach ($this->normalize()->toArray() as $val) {
$part = array();
foreach (explode(';', $val) as $kvp) {
foreach (preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) as $kvp) {
$matches = array();
preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches);
$pieces = array_map($callback, $matches[0]);
$part[$pieces[0]] = isset($pieces[1]) ? $pieces[1] : '';
}
$params[] = $part;

View File

@ -128,11 +128,12 @@ class HeaderTest extends \Guzzle\Tests\GuzzleTestCase
$res1
),
array(
'foo="baz"; bar=123, boo, test="123"',
'foo="baz"; bar=123, boo, test="123", foobar="foo;bar"',
array(
array('foo' => 'baz', 'bar' => '123'),
array('boo' => ''),
array('test' => '123')
array('test' => '123'),
array('foobar' => 'foo;bar')
)
),
array(