Changeset View
Changeset View
Standalone View
Standalone View
src/xsprintf/__tests__/PhutilCsprintfTestCase.php
Context not available. | |||||
// Normal "%s" doesn't do anything special. | // Normal "%s" doesn't do anything special. | ||||
$command = csprintf('php -f %R -- %s', $bin, 'hunter2trustno1'); | $command = csprintf('php -f %R -- %s', $bin, 'hunter2trustno1'); | ||||
$this->assertTrue(strpos($command, 'hunter2trustno1') !== false); | $this->assertTrue(@strpos($command, 'hunter2trustno1') !== false); | ||||
// "%P" takes a PhutilOpaqueEnvelope. | // "%P" takes a PhutilOpaqueEnvelope. | ||||
$caught = null; | $caught = null; | ||||
Context not available. | |||||
'php -f %R -- %P', | 'php -f %R -- %P', | ||||
$bin, | $bin, | ||||
new PhutilOpaqueEnvelope('hunter2trustno1')); | new PhutilOpaqueEnvelope('hunter2trustno1')); | ||||
$this->assertFalse(strpos($command, 'hunter2trustno1')); | $this->assertFalse(@strpos($command, 'hunter2trustno1')); | ||||
// Executing the command works as expected. | // Executing the command works as expected. | ||||
list($out) = execx('%C', $command); | list($out) = execx('%C', $command); | ||||
$this->assertTrue(strpos($out, 'hunter2trustno1') !== false); | $this->assertTrue(@strpos($out, 'hunter2trustno1') !== false); | ||||
} | } | ||||
public function testEscapingIsRobust() { | public function testEscapingIsRobust() { | ||||
Context not available. | |||||
csprintf( | csprintf( | ||||
'echo %P', | 'echo %P', | ||||
new PhutilOpaqueEnvelope('!@#$%^&*()'))))); | new PhutilOpaqueEnvelope('!@#$%^&*()'))))); | ||||
$this->assertTrue(strpos($out, '!@#$%^&*()') !== false); | $this->assertTrue(@strpos($out, '!@#$%^&*()') !== false); | ||||
} | } | ||||
} | } | ||||
Context not available. |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0