Skip to content

Commit 3b8d678

Browse files
authored
Merge pull request #1862 from packagist/url-encode-copy-source-header
AsyncAws S3: URL-encode the CopySource argument
2 parents 235ae80 + 9c0e129 commit 3b8d678

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/AsyncAwsS3/AsyncAwsS3Adapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ public function copy(string $source, string $destination, Config $config): void
357357
'ACL' => $this->visibility->visibilityToAcl($visibility ?: 'private'),
358358
'Bucket' => $this->bucket,
359359
'Key' => $this->prefixer->prefixPath($destination),
360-
'CopySource' => $this->bucket . '/' . $this->prefixer->prefixPath($source),
360+
'CopySource' => rawurlencode($this->bucket . '/' . $this->prefixer->prefixPath($source)),
361361
];
362362

363363
try {

src/AsyncAwsS3/AsyncAwsS3AdapterTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,27 @@ public function copying_a_file_with_visibility(): void
386386
});
387387
}
388388

389+
/**
390+
* @test
391+
*/
392+
public function copying_a_file_with_non_ascii_characters(): void
393+
{
394+
$this->runScenario(function () {
395+
$adapter = $this->adapter();
396+
$adapter->write(
397+
'ıÇöü🤔.txt',
398+
'contents to be copied',
399+
new Config()
400+
);
401+
402+
$adapter->copy('ıÇöü🤔.txt', 'ıÇöü🤔_copy.txt', new Config());
403+
404+
$this->assertTrue($adapter->fileExists('ıÇöü🤔.txt'));
405+
$this->assertTrue($adapter->fileExists('ıÇöü🤔_copy.txt'));
406+
$this->assertEquals('contents to be copied', $adapter->read('ıÇöü🤔_copy.txt'));
407+
});
408+
}
409+
389410
/**
390411
* @test
391412
*/

0 commit comments

Comments
 (0)