Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Process] Fixed escaping arguments on Windows when inheritEnvironmentVariables is set to false #22614

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 1 commit into from
May 22, 2017
Merged

Conversation

maryo
Copy link
Contributor

@maryo maryo commented May 2, 2017

Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? no
Fixed tickets
License MIT
Doc PR

I've added a FAILING testcase on Windows. It incorrectly substitutes an argument containing a quotation mark probably assuming it's an env var needed to backup when inheritEnvironmentVariables is set to false.

@nicolas-grekas
Copy link
Member

nicolas-grekas commented May 2, 2017

Calling inheritEnvironmentVariables(false) is deprecated, which means you're mixing new features and deprecated ones. This should be avoided and is barely supported. Still, would you be able to provide a patch for this issue?

@nicolas-grekas nicolas-grekas added this to the 3.3 milestone May 4, 2017
@maryo maryo changed the title [Process] Added testcase failing on Windows when inheritEnvironmentVariables is set to false [Process] Fixed escaping arguments on Windows when inheritEnvironmentVariables is set to false May 7, 2017
@maryo
Copy link
Contributor Author

maryo commented May 7, 2017

OK. I actually don't use this functionality :-). I just noticed it was not working when I was debugging the failing tests and considered it a BC break. I've updated the PR to fix this.

$var = $uid.++$varCount;
putenv("$var=\"$value\"");

if ($env === null) {
Copy link
Member

Choose a reason for hiding this comment

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

yoda style: null === $env

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

if ($env === null) {
putenv("$var=$value");
} else {
$env[$var] = $value;
Copy link
Member

Choose a reason for hiding this comment

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

Because of line 1656 above, $value will be quoted. It shouldn't, isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nicolas-grekas
I thought the same at the beginning but the argument needs to be escaped even it's passed using the !var! notation (and stored inside the env vars). The tests don't pass without the quotes. BTW I am not exactly sure why it's done using the !var! workarround. Looks like a clever trick and perhaps you are it's author (due to github history/annotations). Is it somehow related to how inconsistently Windows commands handle unescaping of double quotes? (Should be mostly triple quotes and i've found an article describing it but it's not exactly specified so some commands handle it differently). I'm just curious :-)

@xabbuh xabbuh changed the base branch from master to 3.3 May 22, 2017 07:18
@xabbuh
Copy link
Member

xabbuh commented May 22, 2017

@maryo Can you rebase here? I have fixed the base branch given that master now is for Symfony 4.0, but the PR now contains unrelated commits.

@nicolas-grekas
Copy link
Member

please rebase on 3.3 (there should be no merge commit it the PR history)

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

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

👍 (understood & rebased)

@nicolas-grekas
Copy link
Member

Thank you @maryo.

@nicolas-grekas nicolas-grekas merged commit 26032ef into symfony:3.3 May 22, 2017
nicolas-grekas added a commit that referenced this pull request May 22, 2017
…EnvironmentVariables is set to false (maryo)

This PR was merged into the 3.3 branch.

Discussion
----------

[Process]  Fixed escaping arguments on Windows when inheritEnvironmentVariables is set to false

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | no
| Fixed tickets |
| License       | MIT
| Doc PR        |

I've added a FAILING testcase on Windows. It incorrectly substitutes an argument containing a quotation mark probably assuming it's an env var needed to backup when inheritEnvironmentVariables is set to false.

Commits
-------

26032ef [Process] Fixed incorrectly escaping arguments on Windows when inheritEnvironmentVariables is set to false
@fabpot fabpot mentioned this pull request May 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants