1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 13:12:41 +00:00

Deal with trailing whitespace in media types

This commit is contained in:
J. King 2019-09-27 22:54:33 -04:00
parent 4f5a8e3180
commit 1809fb254e
2 changed files with 2 additions and 1 deletions

View file

@ -12,7 +12,7 @@ class HTTP {
public static function matchType(MessageInterface $msg, string ...$type): bool {
$header = $msg->getHeaderLine("Content-Type") ?? "";
foreach ($type as $t) {
$pattern = "/^".preg_quote(trim($t), "/")."($|;|,)/i";
$pattern = "/^".preg_quote(trim($t), "/")."\s*($|;|,)/i";
if (preg_match($pattern, $header)) {
return true;
}

View file

@ -27,6 +27,7 @@ class TestHTTP extends \JKingWeb\Arsse\Test\AbstractTest {
["text/json; charset=utf-8", ["application/json", "text/json"], true],
["", ["application/json"], false],
["", ["application/json", ""], true],
["application/json ;", ["application/json"], true],
];
}
}