|
@@ -13,7 +13,10 @@ class MultipartFormDataParser
|
|
|
throw new \RuntimeException('Invalid multipart Content-Type');
|
|
throw new \RuntimeException('Invalid multipart Content-Type');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $boundary = $m[1] !== '' ? $m[1] : $m[2];
|
|
|
|
|
|
|
+ $boundary = (isset($m[1]) && $m[1] !== '') ? $m[1] : ($m[2] ?? '');
|
|
|
|
|
+ if ($boundary === '') {
|
|
|
|
|
+ throw new \RuntimeException('Missing multipart boundary');
|
|
|
|
|
+ }
|
|
|
$rawBody = (string)$request->getBody();
|
|
$rawBody = (string)$request->getBody();
|
|
|
if ($rawBody === '') {
|
|
if ($rawBody === '') {
|
|
|
$rawBody = (string)file_get_contents('php://input');
|
|
$rawBody = (string)file_get_contents('php://input');
|
|
@@ -33,7 +36,7 @@ class MultipartFormDataParser
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- $split = preg_split("/\r\n\r\n/", $part, 2);
|
|
|
|
|
|
|
+ $split = preg_split("/\r?\n\r?\n/", $part, 2);
|
|
|
if (!$split || count($split) !== 2) {
|
|
if (!$split || count($split) !== 2) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
@@ -72,7 +75,7 @@ class MultipartFormDataParser
|
|
|
private static function parseHeaders(string $rawHeaders): array
|
|
private static function parseHeaders(string $rawHeaders): array
|
|
|
{
|
|
{
|
|
|
$headers = [];
|
|
$headers = [];
|
|
|
- foreach (preg_split('/\r\n/', $rawHeaders) as $line) {
|
|
|
|
|
|
|
+ foreach (preg_split('/\r?\n/', $rawHeaders) as $line) {
|
|
|
$line = trim($line);
|
|
$line = trim($line);
|
|
|
if ($line === '' || strpos($line, ':') === false) {
|
|
if ($line === '' || strpos($line, ':') === false) {
|
|
|
continue;
|
|
continue;
|