Skip to content
Merged
7 changes: 6 additions & 1 deletion src/Formatter/CurlCommandFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ public function formatRequest(RequestInterface $request)
} else {
$data = '[non-seekable stream omitted]';
}
$command .= sprintf(' --data %s', escapeshellarg($data));

$escapedData = @escapeshellarg($data);
if (isset($php_errormsg)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this always be false? Nothing defines $php_errormsg, right?

throw new \InvalidArgumentException($php_errormsg);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not want any exceptions or errors here. We want to silently fail. If we want to be extra nice to the user we may include a error message in the command.

// if fail:
$escapedData = 'We cound not escape the data properly';

}
$command .= sprintf(' --data %s', $escapedData);
}

return $command;
Expand Down