Skip to content

Commit

Permalink
Fix signed URLs on Windows (#577)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdpedrie authored and dwsupplee committed Jul 12, 2017
1 parent 583f34c commit 907e2b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/Storage/StorageObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
10 changes: 5 additions & 5 deletions tests/unit/Storage/StorageObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ public function testSignedUrl()
'contentMd5' => $digest
]);

$input = implode(PHP_EOL, [
$input = implode("\n", [
'GET',
$digest,
$contentType,
Expand Down Expand Up @@ -589,7 +589,7 @@ public function testSignedUrlWithSaveAsName()
'saveAsName' => 'foo'
]);

$input = implode(PHP_EOL, [
$input = implode("\n", [
'GET',
'',
'',
Expand Down Expand Up @@ -622,7 +622,7 @@ public function testSignedUrlConnectionKeyfile()

$url = $object->signedUrl($ts);

$input = implode(PHP_EOL, [
$input = implode("\n", [
'GET',
'',
'',
Expand Down Expand Up @@ -661,7 +661,7 @@ public function testSignedUrlWithSpace()
'contentMd5' => $digest
]);

$input = implode(PHP_EOL, [
$input = implode("\n", [
'GET',
$digest,
$contentType,
Expand Down Expand Up @@ -711,7 +711,7 @@ public function testSignedUploadUrl()
'contentMd5' => $digest
]);

$input = implode(PHP_EOL, [
$input = implode("\n", [
'POST',
$digest,
$contentType,
Expand Down

0 comments on commit 907e2b0

Please sign in to comment.