diff --git a/src/Common/Internal/Authentication/StorageAuthScheme.php b/src/Common/Internal/Authentication/StorageAuthScheme.php index 7dd4b1f2c..7cb3d3a94 100644 --- a/src/Common/Internal/Authentication/StorageAuthScheme.php +++ b/src/Common/Internal/Authentication/StorageAuthScheme.php @@ -181,12 +181,9 @@ protected function computeCanonicalizedResource($url, $queryParams) // 9. Group query parameters // 10. Append a new line character (\n) after each name-value pair. foreach ($queryParams as $key => $value) { - // Grouping query parameters - $values = explode(Resources::SEPARATOR, $value); - sort($values); - $separated = implode(Resources::SEPARATOR, $values); - - $canonicalizedResource .= "\n" . $key . ':' . $separated; + // $value must already be ordered lexicographically + // See: ServiceRestProxy::groupQueryValues + $canonicalizedResource .= "\n" . $key . ':' . $value; } return $canonicalizedResource; diff --git a/tests/unit/Common/Internal/Authentication/StorageAuthSchemeTest.php b/tests/unit/Common/Internal/Authentication/StorageAuthSchemeTest.php index 48c42467e..a0e8fe472 100644 --- a/tests/unit/Common/Internal/Authentication/StorageAuthSchemeTest.php +++ b/tests/unit/Common/Internal/Authentication/StorageAuthSchemeTest.php @@ -24,6 +24,7 @@ namespace MicrosoftAzure\Storage\Tests\Unit\Common\Internal\Authentication; use MicrosoftAzure\Storage\Common\Internal\Authentication\StorageAuthScheme; +use MicrosoftAzure\Storage\Common\Internal\ServiceRestProxy; use MicrosoftAzure\Storage\Tests\Unit\Utilities; use MicrosoftAzure\Storage\Tests\Mock\Common\Internal\Authentication\StorageAuthSchemeMock; use MicrosoftAzure\Storage\Tests\Framework\TestResources; @@ -94,7 +95,13 @@ public function testComputeCanonicalizedResourceMockMultipleValues() { $queryVariables = array(); $queryVariables['COMP'] = 'list'; - $queryVariables[Resources::QP_INCLUDE] = 'snapshots,metadata,uncommittedblobs'; + $queryVariables[Resources::QP_INCLUDE] = ServiceRestProxy::groupQueryValues( + array( + 'snapshots', + 'metadata', + 'uncommittedblobs' + ) + ); $expectedQueryPart = "comp:list\ninclude:metadata,snapshots,uncommittedblobs"; $accountName = TestResources::ACCOUNT_NAME; $url = TestResources::URI1;