Fix urlencode is invalid in some cases

This commit is contained in:
Zhong Lufan 2020-04-19 23:07:02 +08:00
parent 7e6b2eecca
commit b688e3d965
No known key found for this signature in database
GPG Key ID: 373C08F7FFF84D26
2 changed files with 5 additions and 1 deletions

View File

@ -96,6 +96,6 @@ _ali_signature_nonce() {
_urlencode() {
local result
result=$(curl -G -s -o /dev/null -w "%{url_effective}" --data-urlencode "=$1" file:///dev/null)
result=$(curl -G -s -o /dev/null -w "%{url_effective}" --connect-timeout 1 --max-time 1 --data-urlencode "=$1" http://127.0.0.1:65535)
echo "${result#*\?}"
}

View File

@ -13,6 +13,10 @@
* curl
* openssl
## 注意事项
由于 URL 编码使用了 `curl``--data-urlencode` 实现,所以每次 URL 编码都会对本地的 65535 端口发起 HTTP 请求,如果你的 65535 端口不是空闲的,为了避免对你的服务造成影响,建议修改脚本的 `_urlencode` 函数。
## 使用
1. 导出环境变量 `AliAccessKeyId``AliAccessKeySecret`