Changeset 1d9734c
- Timestamp:
- 01/29/12 16:07:12 (4 months ago)
- Branches:
- master
- Children:
- 3286322, 9c52445
- Parents:
- aaec053
- git-author:
- Michiel Rook <mrook@…> (01/29/12 16:07:12)
- git-committer:
- Michiel Rook <mrook@…> (01/29/12 16:07:12)
- Files:
-
- 4 edited
-
classes/phing/tasks/system/ExecTask.php (modified) (1 diff, 1 prop)
-
classes/phing/types/Commandline.php (modified) (3 diffs, 1 prop)
-
test/classes/phing/tasks/system/ExecTaskTest.php (modified) (1 diff, 1 prop)
-
test/etc/tasks/system/ExecTest.xml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
classes/phing/tasks/system/ExecTask.php
- Property mode changed from 100644 to 100755
rddc113f r1d9734c 211 211 ); 212 212 } else if ($this->command === null) { 213 $this->command = (string)$this->commandline;213 $this->command = Commandline::toString($this->commandline->getCommandline(), $this->escape); 214 214 } else if ($this->commandline->getExecutable() === null) { 215 215 //we need to escape the command only if it's specified directly -
classes/phing/types/Commandline.php
- Property mode changed from 100644 to 100755
r9ac2bee r1d9734c 158 158 * and double quotes. 159 159 */ 160 public static function quoteArgument($argument) { 161 if (strpos($argument, "\"") !== false) { 160 public static function quoteArgument($argument, $escape = false) { 161 if ($escape) { 162 return escapeshellarg($argument); 163 } elseif (strpos($argument, "\"") !== false) { 162 164 if (strpos($argument, "'") !== false) { 163 165 throw new BuildException("Can't handle single and double quotes in same argument"); … … 177 179 * usable as command line arguments. 178 180 */ 179 public static function toString($lines ) {181 public static function toString($lines, $escape = false) { 180 182 // empty path return empty string 181 183 if (!$lines) { … … 189 191 $result .= ' '; 190 192 } 191 $result .= self::quoteArgument($lines[$i] );193 $result .= self::quoteArgument($lines[$i], $escape); 192 194 } 193 195 return $result; -
test/classes/phing/tasks/system/ExecTaskTest.php
- Property mode changed from 100644 to 100755
r74ddb43 r1d9734c 350 350 $this->executeTarget(__FUNCTION__); 351 351 } 352 353 /** 354 * Inspired by {@link http://www.phing.info/trac/ticket/833} 355 */ 356 public function testEscapedArg() 357 { 358 $this->executeTarget(__FUNCTION__); 359 $this->assertPropertyEquals('outval', 'abc$b3!SB'); 360 } 352 361 } 353 362 -
test/etc/tasks/system/ExecTest.xml
r74ddb43 r1d9734c 151 151 </exec> 152 152 </target> 153 154 <target name="testEscapedArg"> 155 <exec executable="echo" escape="true" outputProperty="outval"> 156 <arg value="abc$b3!SB"/> 157 </exec> 158 </target> 153 159 154 160 </project>
Note: See TracChangeset
for help on using the changeset viewer.
