1
0
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:
Michael Dowling 2013-08-24 19:15:08 -07:00
parent c0f9f9ee8f
commit efef3c2906
2 changed files with 14 additions and 1 deletions

View File

@ -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]);

View File

@ -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());
}
}