Fixing IE driver setTimeouts command to properly validate JSON payload
@@ -36,6 +36,16 @@ void SetTimeoutsCommandHandler::ExecuteInternal(
ParametersMap::const_iterator timeout_parameter_iterator = command_parameters.begin();
for (; timeout_parameter_iterator != command_parameters.end(); ++timeout_parameter_iterator) {
std::string timeout_type = timeout_parameter_iterator->first;
+ if (timeout_type != "implicit" &&
+ timeout_type != "script" &&
+ timeout_type != "pageLoad") {
+ response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Invalid timeout type specified: " + timeout_type);
+ return;
+ }
+ if (!timeout_parameter_iterator->second.isNumeric()) {
+ response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Timeout value for timeout type" + timeout_type + "must be an integer");
+ return;
+ }
timeout = timeout_parameter_iterator->second.asUInt64();
if (timeout_type == "implicit") {
mutable_executor.set_implicit_wait_timeout(timeout);
@@ -43,9 +53,6 @@ void SetTimeoutsCommandHandler::ExecuteInternal(
mutable_executor.set_async_script_timeout(timeout);
} else if (timeout_type == "pageLoad") {
mutable_executor.set_page_load_timeout(timeout);
- } else {
- response->SetErrorResponse(ERROR_INVALID_ARGUMENT, "Invalid timeout type specified: " + timeout_type);
- return;
}
}
}
