-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
[HttpClient] Replace escapeshellarg
to prevent overpassing ARG_MAX
#52429
[HttpClient] Replace escapeshellarg
to prevent overpassing ARG_MAX
#52429
Conversation
src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php
Show resolved
Hide resolved
88259df
to
d8be8f5
Compare
@nicolas-grekas I really like your idea of leveraging Process. I updated the code to use it first if it exists. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after minor changes
{ | ||
return \strlen($payload) < ('\\' === \DIRECTORY_SEPARATOR ? 8100 : 256000); | ||
if (class_exists(Process::class)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (class_exists(Process::class)) { | |
static $useProcess; | |
if ($useProcess ??= class_exists(Process::class)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I addressed your comments, thanks 🙂
return null; | ||
} | ||
$dataArg[] = '--data '.escapeshellarg($payload); | ||
$dataArg[] = '--data-raw '.$this->sanitizeArg(self::jsonEncode($json)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't sanitize, we escape
return (new Process([$payload]))->getCommandLine(); | ||
} | ||
|
||
if (\DIRECTORY_SEPARATOR === '\\') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (\DIRECTORY_SEPARATOR === '\\') { | |
if ('\\' === \DIRECTORY_SEPARATOR) { |
d8be8f5
to
3b0bb11
Compare
Thank you @alexandre-daubois. |
…nd when files are uploaded (MatTheCat) This PR was merged into the 6.3 branch. Discussion ---------- [HttpClient][WebProfilerBundle] Do not generate cURL command when files are uploaded | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #51366 | License | MIT I also removed ``@requires` extension openssl` annotations since that does not seem to be the case since #45729. Failures in AppVeyor occur because double quotes are missing around `--data-raw` values. Possibly related to #52429. Commits ------- 4503f94 [HttpClient][WebProfilerBundle] Do not generate cURL command when files are uploaded
I'm not 100% sure if it is a bugfix or a feature.
I used Nicolas' suggestion in the issue to sanitize the input and used
--data-raw
to avoid any automatic formatting.Removing the use of
escapeshellarg()
also allows to removeHttpClientDataCollectorTest::testItDoesNotGeneratesCurlCommandsForNotEncodableBody()
. Indeed, the body can now be encoded and will result on the following cURL command: