Skip to content

Commit 0d301b2

Browse files
mvorisekrobocoder
authored andcommitted
Assert curl data are always fully serialized before request
1 parent 04ebf6f commit 0d301b2

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

lib/WebDriver/AbstractWebDriver.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti
161161
$url .= '/' . $parameters;
162162
}
163163

164+
$this->assertNonObjectParameters($parameters);
165+
164166
list($rawResult, $info) = $this->curlService->execute(
165167
$requestMethod,
166168
$url,
@@ -245,6 +247,32 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti
245247
);
246248
}
247249

250+
/**
251+
* @param mixed $parameters
252+
*/
253+
private function assertNonObjectParameters($parameters)
254+
{
255+
if ($parameters === null || is_scalar($parameters)) {
256+
return;
257+
}
258+
259+
if (is_array($parameters)) {
260+
foreach ($parameters as $value) {
261+
$this->assertNonObjectParameters($value);
262+
}
263+
264+
return;
265+
}
266+
267+
throw WebDriverException::factory(
268+
WebDriverException::UNEXPECTED_PARAMETERS,
269+
sprintf(
270+
"Unable to serialize non-scalar type %s",
271+
is_object($parameters) ? get_class($parameters) : gettype($parameters)
272+
)
273+
);
274+
}
275+
248276
/**
249277
* Magic method that maps calls to class methods to execute WebDriver commands
250278
*

0 commit comments

Comments
 (0)