1 | <?php |
||
13 | class Escape |
||
14 | { |
||
15 | /** |
||
16 | * argsForSite escapes each argument in an array for the given site. |
||
17 | */ |
||
18 | public static function argsForSite(AliasRecord $siteAlias, $args) |
||
27 | |||
28 | /** |
||
29 | * forSite escapes the provided argument for the specified alias record. |
||
30 | */ |
||
31 | public static function forSite(AliasRecord $siteAlias, $arg) |
||
35 | |||
36 | /** |
||
37 | * shellArg escapes the provided argument for the specified OS |
||
38 | * |
||
39 | * @param string|ShellOperatorInterface $arg The argument to escape |
||
40 | * @param string|null $os The OS to escape for. Optional; defaults to LINUX |
||
41 | * |
||
42 | * @return string The escaped string |
||
43 | */ |
||
44 | public static function shellArg($arg, $os = null) |
||
58 | |||
59 | /** |
||
60 | * isWindows determines whether the provided OS is Windows. |
||
61 | */ |
||
62 | public static function isWindows($os) |
||
66 | |||
67 | /** |
||
68 | * linuxArg is the Linux version of escapeshellarg(). |
||
69 | * |
||
70 | * This is intended to work the same way that escapeshellarg() does on |
||
71 | * Linux. If we need to escape a string that will be used remotely on |
||
72 | * a Linux system, then we need our own implementation of escapeshellarg, |
||
73 | * because the Windows version behaves differently. |
||
74 | * |
||
75 | * Note that we behave somewhat differently than the built-in escapeshellarg() |
||
76 | * with respect to whitespace replacement in order |
||
77 | * |
||
78 | * @param string $arg The argument to escape |
||
79 | * |
||
80 | * @return string The escaped string |
||
81 | */ |
||
82 | public static function linuxArg($arg) |
||
106 | |||
107 | /** |
||
108 | * windowsArg is the Windows version of escapeshellarg(). |
||
109 | * |
||
110 | * @param string $arg The argument to escape |
||
111 | * |
||
112 | * @return string The escaped string |
||
113 | */ |
||
114 | public static function windowsArg($arg) |
||
133 | } |
||
134 |