Fix #18313: Fix multipart form data parse with double quotes

This commit is contained in:
Walid Said
2020-10-05 12:08:32 +02:00
committed by GitHub
parent 3f3003d823
commit 3dabcdb6ab
3 changed files with 43 additions and 3 deletions

View File

@ -141,10 +141,11 @@ class MultipartFormDataParser extends BaseObject implements RequestParserInterfa
return [];
}
if (!preg_match('/boundary=(.*)$/is', $contentType, $matches)) {
if (!preg_match('/boundary="?(.*)"?$/is', $contentType, $matches)) {
return [];
}
$boundary = $matches[1];
$boundary = trim($matches[1], '"');
$bodyParts = preg_split('/\\R?-+' . preg_quote($boundary, '/') . '/s', $rawBody);
array_pop($bodyParts); // last block always has no data, contains boundary ending like `--`