diff --git a/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php b/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php index 10810581a22b97ddd8af631438da048a783f6e5d..8efbb92d5d945f5cf29aae360160deb0219d67e9 100644 --- a/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php +++ b/core/modules/file/src/Plugin/rest/resource/FileUploadResource.php @@ -377,7 +377,7 @@ protected function validateAndParseContentDispositionHeader(Request $request) { // Make sure only the filename component is returned. Path information is // stripped as per https://tools.ietf.org/html/rfc6266#section-4.3. - return basename($filename); + return $this->fileSystem->basename($filename); } /** diff --git a/core/modules/rest/tests/src/Functional/FileUploadResourceTestBase.php b/core/modules/rest/tests/src/Functional/FileUploadResourceTestBase.php index cb3ef3e27a0ffe0160bad28572992c8ab63ccb4b..994a4c3ccb51b079922c096e6e389fa33d9f1fea 100644 --- a/core/modules/rest/tests/src/Functional/FileUploadResourceTestBase.php +++ b/core/modules/rest/tests/src/Functional/FileUploadResourceTestBase.php @@ -373,11 +373,13 @@ public function testFileUploadUnicodeFilename() { $uri = Url::fromUri('base:' . static::$postUri); - $response = $this->fileRequest($uri, $this->testFileData, ['Content-Disposition' => 'file; filename="example-✓.txt"']); + // It is important that the filename starts with a unicode character. See + // https://bugs.php.net/bug.php?id=77239. + $response = $this->fileRequest($uri, $this->testFileData, ['Content-Disposition' => 'file; filename="Èxample-✓.txt"']); $this->assertSame(201, $response->getStatusCode()); - $expected = $this->getExpectedNormalizedEntity(1, 'example-✓.txt', TRUE); + $expected = $this->getExpectedNormalizedEntity(1, 'Èxample-✓.txt', TRUE); $this->assertResponseData($expected, $response); - $this->assertSame($this->testFileData, file_get_contents('public://foobar/example-✓.txt')); + $this->assertSame($this->testFileData, file_get_contents('public://foobar/Èxample-✓.txt')); } /**