Page MenuHomePhabricator

Allow PhutilCommandString to escape as Powershell
ClosedPublic

Authored by hach-que on Aug 13 2014, 1:37 AM.
Tags
None
Referenced Files
F19148486: D10249.id.diff
Wed, Dec 10, 5:46 PM
F19104321: D10249.id.diff
Fri, Dec 5, 1:31 PM
F19102652: D10249.id.diff
Fri, Dec 5, 7:14 AM
F18959906: D10249.diff
Nov 13 2025, 9:05 AM
F18931628: D10249.id24672.diff
Nov 10 2025, 3:28 AM
F18852980: D10249.id.diff
Oct 31 2025, 1:24 PM
F18839047: D10249.id24663.diff
Oct 27 2025, 2:05 PM
F18817161: D10249.id24671.diff
Oct 21 2025, 1:05 PM
Subscribers

Details

Summary

This allows PhutilCommandString to escape as Powershell.

Test Plan

Unit tests

Diff Detail

Repository
rPHU libphutil
Lint
Lint Skipped
Unit
Tests Skipped

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
66

Putting:

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

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

164

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
33–36

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

43

...then pass 'mode'

src/xsprintf/__tests__/PhutilCsprintfTestCase.php
27

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
111–112

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.

149

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

150

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).