Page MenuHomePhabricator

Allow PhutilCommandString to escape as Powershell
ClosedPublic

Authored by hach-que on Aug 13 2014, 1:37 AM.
Tags
None
Referenced Files
Unknown Object (File)
May 20 2025, 6:39 AM
Unknown Object (File)
May 19 2025, 8:22 AM
Unknown Object (File)
May 14 2025, 10:54 AM
Unknown Object (File)
May 9 2025, 6:53 PM
Unknown Object (File)
May 7 2025, 1:21 PM
Unknown Object (File)
May 6 2025, 9:18 AM
Unknown Object (File)
Apr 23 2025, 1:34 AM
Unknown Object (File)
Apr 21 2025, 11:01 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).