From ce2373c3d122cbe854e26c1b0b20e5e5cc220cf7 Mon Sep 17 00:00:00 2001 From: lewzylu Date: Sun, 27 Sep 2020 11:21:01 +0800 Subject: [PATCH] fix signature with urlencode --- src/Qcloud/Cos/Signature.php | 4 ++-- src/Qcloud/Cos/Tests/COSTest.php | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/Qcloud/Cos/Signature.php b/src/Qcloud/Cos/Signature.php index ab1b06e9..1ea516df 100644 --- a/src/Qcloud/Cos/Signature.php +++ b/src/Qcloud/Cos/Signature.php @@ -54,9 +54,9 @@ public function createAuthorization( RequestInterface $request, $expires = '+30 foreach ( explode( '&', $request->getUri()->getQuery() ) as $query ) { if (!empty($query)) { $tmpquery = explode( '=', $query ); - $key = strtolower( urlencode( $tmpquery[0] ) ); + $key = strtolower( $tmpquery[0] ); if (count($tmpquery) >= 2) { - $value = urlencode( $tmpquery[1] ); + $value = $tmpquery[1]; } else { $value = ""; } diff --git a/src/Qcloud/Cos/Tests/COSTest.php b/src/Qcloud/Cos/Tests/COSTest.php index b0ad6d7a..f0ce2fb0 100644 --- a/src/Qcloud/Cos/Tests/COSTest.php +++ b/src/Qcloud/Cos/Tests/COSTest.php @@ -554,6 +554,23 @@ public function testGetBucketEmpty() } } + /* + * get bucket, prefix为中文 + * 200 + */ + public function testGetBucketWithChinese() + { + try { + $this->cosClient->ListObjects(array( + 'Bucket' => $this->bucket, + 'Prefix' => '中文', + 'Delimiter' => '/')); + } catch (ServiceResponseException $e) { + print $e; + $this->assertFalse(TRUE); + } + } + /* * get bucket,bucket不存在 * NoSuchBucket @@ -1009,7 +1026,7 @@ public function testPutObjectMeta() { $key = '你好.txt'; $meta = array( 'test' => str_repeat('a', 1 * 1024), - 'test-meta' => 'qwe-23ds-ad-xcz.asd.*qweqw' + 'test-meta' => '中文qwe-23ds-ad-xcz.asd.*qweqw' ); $this->cosClient->putObject(array( 'Bucket' => $this->bucket,