Changeset View
Changeset View
Standalone View
Standalone View
src/xsprintf/PhutilCommandString.php
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | public static function escapeArgument($value, $mode) { | ||||
if ($mode === self::MODE_DEFAULT) { | if ($mode === self::MODE_DEFAULT) { | ||||
if (phutil_is_windows()) { | if (phutil_is_windows()) { | ||||
$mode = self::MODE_WINDOWS; | $mode = self::MODE_WINDOWS; | ||||
} else { | } else { | ||||
$mode = self::MODE_LINUX; | $mode = self::MODE_LINUX; | ||||
} | } | ||||
} | } | ||||
// Be generous about what we accept | |||||
// but normalize to a value that makes sense for a command line | |||||
// premising that CLIs only accept strings since that is how computers work | |||||
if ($value === null) { | |||||
$value = ''; | |||||
} | |||||
switch ($mode) { | switch ($mode) { | ||||
case self::MODE_LINUX: | case self::MODE_LINUX: | ||||
return self::escapeLinux($value); | return self::escapeLinux($value); | ||||
case self::MODE_WINDOWS: | case self::MODE_WINDOWS: | ||||
return self::escapeWindows($value); | return self::escapeWindows($value); | ||||
case self::MODE_POWERSHELL: | case self::MODE_POWERSHELL: | ||||
return self::escapePowershell($value); | return self::escapePowershell($value); | ||||
default: | default: | ||||
▲ Show 20 Lines • Show All 105 Lines • Show Last 20 Lines |
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