Skip to content

Commit ffc42b5

Browse files
committed
Fixed: error when a JSON payload is an array and previously decoded.
1 parent 87c1e35 commit ffc42b5

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/Request.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function getParameterValues($parameter, $data = [])
9797
}
9898

9999
// Determine if it's base64 encoded.
100-
if (preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $data)) {
100+
if (is_string($data) && preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $data)) {
101101
$decoded = base64_decode($data, true);
102102
if ($decoded !== false) {
103103
$encoding = mb_detect_encoding($decoded);
@@ -108,9 +108,11 @@ public function getParameterValues($parameter, $data = [])
108108
}
109109

110110
// Determine if it's JSON encoded.
111-
$result = json_decode($data, true);
112-
if (is_array($result)) {
113-
$data = $result;
111+
if (is_string($data)) {
112+
$result = json_decode($data, true);
113+
if (is_array($result)) {
114+
$data = $result;
115+
}
114116
}
115117

116118
// If it's not an array, no need to continue.

0 commit comments

Comments
 (0)