diff --git a/src/Storage/StorageObject.php b/src/Storage/StorageObject.php index c747954bc27f..b1cbb7f05bc3 100644 --- a/src/Storage/StorageObject.php +++ b/src/Storage/StorageObject.php @@ -786,10 +786,12 @@ public function signedUrl($expires, array $options = []) $options['contentMd5'], $options['contentType'], $seconds, - implode(PHP_EOL, $headers) . $resource, + implode("\n", $headers) . $resource, ]; - $string = implode(PHP_EOL, $toSign); + // NOTE: While in most cases `PHP_EOL` is preferable to a system-specific character, + // in this case `\n` is required. + $string = implode("\n", $toSign); $signature = $this->signString($keyFile['private_key'], $string, $options['forceOpenssl']); $encodedSignature = urlencode(base64_encode($signature)); diff --git a/tests/unit/Storage/StorageObjectTest.php b/tests/unit/Storage/StorageObjectTest.php index 89b697e22b6f..40315eea7d6b 100644 --- a/tests/unit/Storage/StorageObjectTest.php +++ b/tests/unit/Storage/StorageObjectTest.php @@ -554,7 +554,7 @@ public function testSignedUrl() 'contentMd5' => $digest ]); - $input = implode(PHP_EOL, [ + $input = implode("\n", [ 'GET', $digest, $contentType, @@ -589,7 +589,7 @@ public function testSignedUrlWithSaveAsName() 'saveAsName' => 'foo' ]); - $input = implode(PHP_EOL, [ + $input = implode("\n", [ 'GET', '', '', @@ -622,7 +622,7 @@ public function testSignedUrlConnectionKeyfile() $url = $object->signedUrl($ts); - $input = implode(PHP_EOL, [ + $input = implode("\n", [ 'GET', '', '', @@ -661,7 +661,7 @@ public function testSignedUrlWithSpace() 'contentMd5' => $digest ]); - $input = implode(PHP_EOL, [ + $input = implode("\n", [ 'GET', $digest, $contentType, @@ -711,7 +711,7 @@ public function testSignedUploadUrl() 'contentMd5' => $digest ]); - $input = implode(PHP_EOL, [ + $input = implode("\n", [ 'POST', $digest, $contentType,