From 907e2b0e506d23567c8eaf0a77a2ed6c087a6b62 Mon Sep 17 00:00:00 2001 From: John Pedrie Date: Wed, 12 Jul 2017 14:06:59 -0400 Subject: [PATCH] Fix signed URLs on Windows (#577) --- src/Storage/StorageObject.php | 6 ++++-- tests/unit/Storage/StorageObjectTest.php | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) 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,