Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 9727eb3

Browse files
committed
Add a test
Test correct handling of accept headers with semicolon without equal sign
1 parent ea5b38c commit 9727eb3

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Header/AbstractAccept.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,12 @@ protected function getParametersFromFieldValuePart($fieldValuePart)
170170
foreach ($paramsStrings as $param) {
171171
$explode = explode('=', $param, 2);
172172

173-
$value = trim($explode[1]);
173+
if (count($explode) === 2) {
174+
$value = trim($explode[1]);
175+
} else {
176+
$value = trim($param);
177+
}
178+
174179
if (isset($value[0]) && $value[0] == '"' && substr($value, -1) == '"') {
175180
$value = substr(substr($value, 1), 0, -1);
176181
}

test/Header/AcceptCharsetTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ public function testAcceptCharsetGetFieldValueReturnsProperValue()
3232
$this->assertEquals('xxx', $acceptCharsetHeader->getFieldValue());
3333
}
3434

35+
public function testAcceptCharsetGetFieldValueReturnsProperValueWithSemicolonWithoutEqualSign()
36+
{
37+
$acceptCharsetHeader = AcceptCharset::fromString('Accept-Charset: xxx;yyy');
38+
$this->assertEquals('xxx;yyy', $acceptCharsetHeader->getFieldValue());
39+
}
40+
3541
public function testAcceptCharsetToStringReturnsHeaderFormattedString()
3642
{
3743
$acceptCharsetHeader = new AcceptCharset();

0 commit comments

Comments
 (0)