mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-12-25 13:44:09 -08:00
Merge pull request #1594 from GOGOsu/patch-1
Fix aliyun-sms "SignatureDoesNotMatch" Error
This commit is contained in:
commit
29f3cbe8c6
|
@ -93,8 +93,23 @@ class AliyunSMS extends NotificationProvider {
|
|||
param2[key] = param[key];
|
||||
}
|
||||
|
||||
// Escape more characters than encodeURIComponent does.
|
||||
// For generating Aliyun signature, all characters except A-Za-z0-9~-._ are encoded.
|
||||
// See https://help.aliyun.com/document_detail/315526.html
|
||||
// This encoding methods as known as RFC 3986 (https://tools.ietf.org/html/rfc3986)
|
||||
let moreEscapesTable = function (m) {
|
||||
return {
|
||||
"!": "%21",
|
||||
"*": "%2A",
|
||||
"'": "%27",
|
||||
"(": "%28",
|
||||
")": "%29"
|
||||
}[m];
|
||||
};
|
||||
|
||||
for (let key in param2) {
|
||||
data.push(`${encodeURIComponent(key)}=${encodeURIComponent(param2[key])}`);
|
||||
let value = encodeURIComponent(param2[key]).replace(/[!*'()]/g, moreEscapesTable);
|
||||
data.push(`${encodeURIComponent(key)}=${value}`);
|
||||
}
|
||||
|
||||
let StringToSign = `POST&${encodeURIComponent("/")}&${encodeURIComponent(data.join("&"))}`;
|
||||
|
|
Loading…
Reference in a new issue