Skip to content
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

Fix PHP String Concatenation in Output Panel Interpreted as Shell Commands #326

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

N1ebieski
Copy link
Contributor

@N1ebieski N1ebieski commented Mar 10, 2025

Fixes #271, #329

If the contents of the file with the PHP code contains string with concatenation for example:

<?php

$className = "App\\DynamicApp\\Models\\" . ucfirst($relationshipField->attribute) . "Model";

then the command will look like this:

php-parser detect "<?php

\$className = \"App\\DynamicApp\\Models\\\\" . ucfirst(\$relationshipField->attribute) . \"Model\";"

There is one more backslash after "Models\\" than there should be. Then the command returns an error:

bash: syntax error near unexpected token ('`

I suggest to remove one backslash from replacements in the cleanArg function:

replacements.push([/\\"/g, '\\\"']);

because 2nd replacement in the line:

replacements.push([/\"/g, '\\"']);

duplicates backslashes in that case.

@joetannenbaum
Copy link
Collaborator

The problem is that this breaks something like the following:

$myName = "Joe \"Howdy\" Tannenbaum";

Searching out a more reliable (preferably built-in) argument escaping mechanism in Node that works well cross-platform.

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.

[Bug]: PHP String Concatenation in Output Panel Interpreted as Shell Commands
2 participants