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

Unwanted spaces in attribute with forced escape in ExecTask #637

Closed
AKhrulev opened this issue Dec 28, 2016 · 2 comments
Closed

Unwanted spaces in attribute with forced escape in ExecTask #637

AKhrulev opened this issue Dec 28, 2016 · 2 comments
Labels
Milestone

Comments

@AKhrulev
Copy link

Version: Phing 2.15.2
Note: incomplete fix of https://www.phing.info/trac/ticket/1243
Tested on Windows

Steps

Execute command with argument which needs escape:

$exec = $this->project->createTask( 'exec' );
$exec->setExecutable( "echo" );
$arg = $exec->createArg();
$arg->setValue( "foo|bar" );
$arg->setEscape( TRUE );
$exec->main();

Expected

Command is executed:
echo "foo|bar" 2>&1

Actual

Command is executed:
echo " foo|bar " 2>&1
There are two unwanted spaces in argument.

Root cause

Argument is escaped twice. Look at row 229 in file ExecTask.php:
$this->realCommand = Commandline::toString($this->commandline->getCommandline(), $this->escape);
Function $this->commandline->getCommandline() returns escaped argument. Then Commandline::toString() escapes again with function escapeshellarg() called in Commandline::quoteArgument(). This second escaping converts quotation marks to spaces.

Fix: remove double escaping.

@siad007 siad007 added the defect label Jun 24, 2017
@siad007 siad007 self-assigned this Jun 24, 2017
@siad007 siad007 added this to the 3.0 milestone Jun 24, 2017
@siad007 siad007 removed their assignment Aug 22, 2017
@mrook mrook modified the milestones: 3.0, 3.0 RC2 Dec 18, 2017
@stale
Copy link

stale bot commented Jun 16, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jun 16, 2018
@siad007 siad007 removed the wontfix label Jun 30, 2018
@siad007
Copy link
Member

siad007 commented Jul 2, 2018

Fixed in #735

@siad007 siad007 closed this as completed Jul 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants