Skip to content

Commit

Permalink
fix(BosClient): getObject&getObjectToFile方法增加key校验; bump: 1.0.0-rc.31
Browse files Browse the repository at this point in the history
  • Loading branch information
lurunze1226 committed Aug 13, 2021
1 parent b1dec68 commit aabb373
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 9 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# CHANGELOG

## 1.0.0-rc.31(2021-08-13)
### Fix
- BOSClient: add key valiation in getObject() & getObjectToFile() method;
- empty key is not allowed
- consecutive forward slashes (/) are not allowed in key
- forward slash (/) and a backslash (\\) are not allowed at head or tail
- consecutive periods (..) are not allowed in sub-path

## 1.0.0-rc.30(2021-08-03)
### Fix
- BOSClient: fix issue of lack of '/' prefix of object url;
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ Baidu Cloud Engine JavaScript SDK

## 通过CDN引用
```html
<script src="https://code.bdstatic.com/npm/@baiducloud/sdk@1.0.0-rc.30/dist/baidubce-sdk.bundle.min.js" ></script>
<script src="https://code.bdstatic.com/npm/@baiducloud/sdk@1.0.0-rc.31/dist/baidubce-sdk.bundle.min.js" ></script>
```
28 changes: 27 additions & 1 deletion dist/baidubce-sdk.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -44710,7 +44710,7 @@ exports.createContext = Script.createContext = function (context) {
},{"indexof":134}],208:[function(require,module,exports){
module.exports={
"name": "@baiducloud/sdk",
"version": "1.0.0-rc.30",
"version": "1.0.0-rc.31",
"description": "Baidu Cloud Engine JavaScript SDK",
"main": "./index.js",
"browser": {
Expand Down Expand Up @@ -46138,6 +46138,19 @@ BosClient.prototype.getObjectMetadata = function (bucketName, key, options) {
};

BosClient.prototype.getObject = function (bucketName, key, range, options) {
if (!key) {
throw new TypeError('key should not be empty.');
}
else if (/\/\/+/.test(key)) {
throw new TypeError('key should not contain consecutive forward slashes (/).');
}
else if (/^[/\\]/.test(key) || /[/\\]$/.test(key)) {
throw new TypeError('key should not start or end with a forward slash (/) or a backslash (\\).');
}
else if (/\/\.\.\//.test(key)) {
throw new TypeError('path in key should not contain consecutive periods (..).');
}

options = options || {};

var outputStream = new WMStream();
Expand All @@ -46156,6 +46169,19 @@ BosClient.prototype.getObject = function (bucketName, key, range, options) {
};

BosClient.prototype.getObjectToFile = function (bucketName, key, filename, range, options) {
if (!key) {
throw new TypeError('key should not be empty.');
}
else if (/\/\/+/.test(key)) {
throw new TypeError('key should not contain consecutive forward slashes (/).');
}
else if (/^[/\\]/.test(key) || /[/\\]$/.test(key)) {
throw new TypeError('key should not start or end with a forward slash (/) or a backslash (\\).');
}
else if (/\/\.\.\//.test(key)) {
throw new TypeError('path in key should not contain consecutive periods (..).');
}

options = options || {};

return this.sendRequest('GET', {
Expand Down
10 changes: 5 additions & 5 deletions dist/baidubce-sdk.bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@baiducloud/sdk",
"version": "1.0.0-rc.30",
"version": "1.0.0-rc.31",
"description": "Baidu Cloud Engine JavaScript SDK",
"main": "./index.js",
"browser": {
Expand Down
26 changes: 26 additions & 0 deletions src/bos_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,19 @@ BosClient.prototype.getObjectMetadata = function (bucketName, key, options) {
};

BosClient.prototype.getObject = function (bucketName, key, range, options) {
if (!key) {
throw new TypeError('key should not be empty.');
}
else if (/\/\/+/.test(key)) {
throw new TypeError('key should not contain consecutive forward slashes (/).');
}
else if (/^[/\\]/.test(key) || /[/\\]$/.test(key)) {
throw new TypeError('key should not start or end with a forward slash (/) or a backslash (\\).');
}
else if (/\/\.\.\//.test(key)) {
throw new TypeError('path in key should not contain consecutive periods (..).');
}

options = options || {};

var outputStream = new WMStream();
Expand All @@ -523,6 +536,19 @@ BosClient.prototype.getObject = function (bucketName, key, range, options) {
};

BosClient.prototype.getObjectToFile = function (bucketName, key, filename, range, options) {
if (!key) {
throw new TypeError('key should not be empty.');
}
else if (/\/\/+/.test(key)) {
throw new TypeError('key should not contain consecutive forward slashes (/).');
}
else if (/^[/\\]/.test(key) || /[/\\]$/.test(key)) {
throw new TypeError('key should not start or end with a forward slash (/) or a backslash (\\).');
}
else if (/\/\.\.\//.test(key)) {
throw new TypeError('path in key should not contain consecutive periods (..).');
}

options = options || {};

return this.sendRequest('GET', {
Expand Down

0 comments on commit aabb373

Please sign in to comment.