mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-11 19:20:01 +08:00
Fix #17632: Unicode file name was not correctly parsed in multipart forms
This commit is contained in:
committed by
Alexander Makarov
parent
439a5c6681
commit
9c5cd51a3b
@@ -4,6 +4,7 @@ Yii Framework 2 Change Log
|
|||||||
2.0.30 under development
|
2.0.30 under development
|
||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
|
- Bug #17632: Unicode file name was not correctly parsed in multipart forms (AlexRas007, samdark)
|
||||||
- Bug #17648: Handle empty column arrays in console `Table` widget (alex-code)
|
- Bug #17648: Handle empty column arrays in console `Table` widget (alex-code)
|
||||||
- Bug #17657: Fix migration errors from missing `$schema` in RBAC init file when using MSSQL (PoohOka)
|
- Bug #17657: Fix migration errors from missing `$schema` in RBAC init file when using MSSQL (PoohOka)
|
||||||
|
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ class MultipartFormDataParser extends BaseObject implements RequestParserInterfa
|
|||||||
private function parseHeaders($headerContent)
|
private function parseHeaders($headerContent)
|
||||||
{
|
{
|
||||||
$headers = [];
|
$headers = [];
|
||||||
$headerParts = preg_split('/\\R/s', $headerContent, -1, PREG_SPLIT_NO_EMPTY);
|
$headerParts = preg_split('/\\R/su', $headerContent, -1, PREG_SPLIT_NO_EMPTY);
|
||||||
foreach ($headerParts as $headerPart) {
|
foreach ($headerParts as $headerPart) {
|
||||||
if (strpos($headerPart, ':') === false) {
|
if (strpos($headerPart, ':') === false) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -180,4 +180,21 @@ class MultipartFormDataParserTest extends TestCase
|
|||||||
$this->assertNotEmpty($_FILES['someFile']);
|
$this->assertNotEmpty($_FILES['someFile']);
|
||||||
$this->assertFalse(isset($_FILES['existingFile']));
|
$this->assertFalse(isset($_FILES['existingFile']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testParseUnicodeInFileName()
|
||||||
|
{
|
||||||
|
$unicodeName = 'х.jpg'; // this is Russian "х"
|
||||||
|
|
||||||
|
$parser = new MultipartFormDataParser();
|
||||||
|
|
||||||
|
$boundary = '---------------------------703835582829016869506105';
|
||||||
|
$contentType = 'multipart/form-data; boundary=' . $boundary;
|
||||||
|
$rawBody = "--{$boundary}\nContent-Disposition: form-data; name=\"someFile\"; filename=\"$unicodeName\";\nContent-Type: image/jpeg\r\n\r\nsome file content";
|
||||||
|
$rawBody .= "\r\n--{$boundary}--";
|
||||||
|
|
||||||
|
$parser->parse($rawBody, $contentType);
|
||||||
|
|
||||||
|
$this->assertNotEmpty($_FILES['someFile']);
|
||||||
|
$this->assertSame($unicodeName, $_FILES['someFile']['name']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user