mirror of
https://github.com/guzzle/guzzle.git
synced 2025-02-24 18:13:00 +01:00
Only exploding on header glue when not inside of a comma. Closes #411
This commit is contained in:
parent
c0f9f9ee8f
commit
efef3c2906
@ -81,7 +81,8 @@ class Header implements HeaderInterface
|
||||
|
||||
for ($i = 0, $total = count($values); $i < $total; $i++) {
|
||||
if (strpos($values[$i], $this->glue) !== false) {
|
||||
foreach (explode($this->glue, $values[$i]) as $v) {
|
||||
// Explode on glue when the glue is not inside of a comma
|
||||
foreach (preg_split('/' . preg_quote($this->glue) . '(?=([^"]*"[^"]*")*[^"]*$)/', $values[$i]) as $v) {
|
||||
$values[] = trim($v);
|
||||
}
|
||||
unset($values[$i]);
|
||||
|
@ -48,4 +48,16 @@ class LinkTest extends GuzzleTestCase
|
||||
(string) $link
|
||||
);
|
||||
}
|
||||
|
||||
public function testCanParseLinksWithCommas()
|
||||
{
|
||||
$link = new Link('Link', '<http://example.com/TheBook/chapter1>; rel="previous"; title="start, index"');
|
||||
$this->assertEquals(array(
|
||||
array(
|
||||
'rel' => 'previous',
|
||||
'title' => 'start, index',
|
||||
'url' => 'http://example.com/TheBook/chapter1',
|
||||
)
|
||||
), $link->getLinks());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user