Skip to content

Commit c893a53

Browse files
mvorisekrobocoder
authored andcommitted
Assert curl data are always fully serialized before request
1 parent b5b18bd commit c893a53

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
@@ -120,6 +120,8 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti
120120
$url .= '/' . $parameters;
121121
}
122122

123+
$this->assertNonObjectParameters($parameters);
124+
123125
list($rawResult, $info) = ServiceFactory::getInstance()->getService('service.curl')->execute($requestMethod, $url, $parameters, $extraOptions);
124126

125127
$httpCode = $info['http_code'];
@@ -197,6 +199,32 @@ protected function curl($requestMethod, $command, $parameters = null, $extraOpti
197199
);
198200
}
199201

202+
/**
203+
* @param mixed $parameters
204+
*/
205+
private function assertNonObjectParameters($parameters)
206+
{
207+
if ($parameters === null || is_scalar($parameters)) {
208+
return;
209+
}
210+
211+
if (is_array($parameters)) {
212+
foreach ($parameters as $value) {
213+
$this->assertNonObjectParameters($value);
214+
}
215+
216+
return;
217+
}
218+
219+
throw WebDriverException::factory(
220+
WebDriverException::UNEXPECTED_PARAMETERS,
221+
sprintf(
222+
"Unable to serialize non-scalar type %s",
223+
is_object($parameters) ? get_class($parameters) : gettype($parameters)
224+
)
225+
);
226+
}
227+
200228
/**
201229
* Magic method that maps calls to class methods to execute WebDriver commands
202230
*

0 commit comments

Comments
 (0)