Skip to content

Commit 3b0064a

Browse files
committed
🐛 Fix for & or = in the body:
- replace either with a `_` for the purpose of the signature - keep the original arguments in the request - TODO: need to test with inbound requests
1 parent 1ac4952 commit 3b0064a

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/Client/Signature.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,16 @@ public function __construct(array $params, $secret)
4343
//sort params
4444
ksort($this->signed);
4545

46+
$signed = [];
47+
foreach ($this->signed as $key => $value) {
48+
$signed[$key] = str_replace(array("&", "="), "_", $value);
49+
}
50+
4651
//create base string
47-
$base = '&'.urldecode(http_build_query($this->signed));
52+
$base = '&'.urldecode(http_build_query($signed));
4853

4954
//append the secret
50-
$base .= $secret;
55+
$base .= $secret;
5156

5257
//create hash
5358
$this->signed['sig'] = md5($base);

test/Client/SignatureTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,15 @@ public function signatures()
8585
'to' => '14849970568',
8686
'type' => 'text',
8787
'sig' => '83c052a82906ec7c116e16f6d92f7eee'
88-
), 'my_secret_key_for_testing')
88+
), 'my_secret_key_for_testing'),
89+
array('17f5e3b22f778ec73464c01d180e9d0f', array(
90+
'api_key' => 'not_a_key',
91+
'from' => '12192259404',
92+
'text' => '14843472194',
93+
'text' => 'Test&test=something',
94+
'timestamp' => '1490638615',
95+
'to' => '14843472194',
96+
), 'my_secret_key_for_testing'),
8997
);
9098
}
9199

0 commit comments

Comments
 (0)