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:
parent
c43b822e02
commit
13178c36b0
@ -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;
|
||||
|
@ -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(
|
||||
|
Loading…
x
Reference in New Issue
Block a user