Skip to content

Bug/curl fromater fails #94

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 9, 2018
Merged

Conversation

llaakkkk
Copy link
Contributor

@llaakkkk llaakkkk commented Mar 7, 2018

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Related tickets fixes #93
License MIT

What's in this PR?

Added suppress to CurlFormatter for big file error.

@llaakkkk
Copy link
Contributor Author

llaakkkk commented Mar 7, 2018

I create PR, but I have several variants of task solve, but I don’t know which is needed.
Also, another solution can be by count NULL bytes in a string. What do you think about it?

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

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

Great. Thank you.

We may also want to check if $data is empty before we try to escape it.

$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?


$escapedData = @escapeshellarg($data);
if (isset($php_errormsg)) {
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';

@@ -45,7 +45,11 @@ public function formatRequest(RequestInterface $request)
} else {
$data = '[non-seekable stream omitted]';
}
$command .= sprintf(' --data %s', escapeshellarg($data));

$escapedData = @escapeshellarg($data) or
Copy link
Member

Choose a reason for hiding this comment

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

Lets make this more pretty by doing multiple lines.

$escapedData = @escapeshellarg($data);
if (empty($escapedData)) {
  $escapedData = 'We couldn't not escape the data properly';
}

@Nyholm
Copy link
Member

Nyholm commented May 8, 2018

Any updates on this PR?

@llaakkkk
Copy link
Contributor Author

llaakkkk commented May 8, 2018

@Nyholm I'll do it asap

@joelwurtz
Copy link
Member

Thanks, you good for me, poke @Nyholm

Copy link
Member

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

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

Looks good. I missed the notification for your last commit.

Good job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CurlFormatter fails on large boddies
3 participants