Page MenuHomePhabricator

Allow PhutilCommandString to escape as Powershell
ClosedPublic

Authored by hach-que on Aug 13 2014, 1:37 AM.
Tags
None
Referenced Files
F14398740: D10249.diff
Sun, Dec 22, 2:38 PM
Unknown Object (File)
Thu, Dec 12, 4:07 AM
Unknown Object (File)
Sun, Dec 8, 3:28 PM
Unknown Object (File)
Sun, Dec 8, 2:06 PM
Unknown Object (File)
Wed, Dec 4, 11:18 PM
Unknown Object (File)
Wed, Dec 4, 10:31 PM
Unknown Object (File)
Tue, Dec 3, 9:10 PM
Unknown Object (File)
Tue, Dec 3, 9:10 PM
Subscribers

Details

Summary

This allows PhutilCommandString to escape as Powershell.

Test Plan

Unit tests

Diff Detail

Repository
rPHU libphutil
Branch
escape-powershell
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 2192
Build 2196: [Placeholder Plan] Wait for 30 Seconds

Event Timeline

hach-que retitled this revision from to Allow PhutilCommandString to escape as Powershell.
hach-que updated this object.
hach-que edited the test plan for this revision. (Show Details)
hach-que added a reviewer: epriestley.
hach-que added a subscriber: epriestley.
src/xsprintf/csprintf.php
61

Putting:

if ($is_powershell) {
  throw new Exception('blah');
}

does get hit and causes __toString() can not throw exception in the daemon log.

171

But the command that's run is never this, and always appears to use UNIX escaping.

hach-que edited edge metadata.

Now working

epriestley edited edge metadata.
epriestley added inline comments.
src/xsprintf/PhutilCommandString.php
28–31

Let's make this setEscapingMode(PhutilCommandString::MODE_POWERSHELL) or similar.

38

...then pass 'mode'

src/xsprintf/__tests__/PhutilCsprintfTestCase.php
27 ↗(On Diff #24663)

Then eventually this test would become setEscapingMode(PhutilCommandString::MODE_LINUX) and the test would work under windows, in a future far away.

src/xsprintf/csprintf.php
106–111

Let's move this to PhutilCommandString::escapeArgument($argument, $mode = PhutilCommandString::MODE_DEFAULT) instead of defining a new escapepowershell. That should reduce code duplication too, and make real modal operation easy to implement later.

156

In single quotes, I think this means literally "backslash a".

157

Same issue here, this is "backslash b"

This revision now requires changes to proceed.Aug 13 2014, 2:07 AM
hach-que edited edge metadata.

Changes based on feedback

hach-que edited edge metadata.

Change \a and \b to use chr()

epriestley edited edge metadata.
This revision is now accepted and ready to land.Aug 13 2014, 2:34 AM
hach-que updated this revision to Diff 24672.

Closed by commit rPHU49f08a756a54 (authored by @hach-que).