Closed
Description
Q | A |
---|---|
Bug? | yes |
New Feature? | no |
Version | master (977edb5) |
Actual Behavior
Using CurlCommandFormatter
to format a HTTP request with a binary payload throws an exception:
Error: escapeshellarg(): Input string contains NULL bytes
at vendor/php-http/message/src/Formatter/CurlCommandFormatter.php:43
Expected Behavior
The formatter throws a proper exception or outputs a valid (possibly incomplete) command (see below).
Steps to Reproduce
$requestFactory = Http\Discovery\MessageFactoryDiscovery::find();
$request = $requestFactory->createRequest('POST', 'http://example.com', [], "\0");
$formatter = new Http\Message\Formatter\CurlCommandFormatter();
$formatter->formatRequest($request);
Possible Solutions
In case the formatter should output a command at any times, it should either escape null bytes properly or remove the payload completely. Other tools, such as the network monitor of Firefox, only include url-encoded payloads or multipart parts with Content-Disposition: form-data
in the command.
Metadata
Metadata
Assignees
Labels
No labels