|
24 | 24 |
|
25 | 25 | namespace OCA\WorkflowScript; |
26 | 26 |
|
27 | | -use Exception; |
28 | | -use InvalidArgumentException; |
29 | | -use OC\Files\View; |
30 | 27 | use OC\User\NoUserException; |
31 | 28 | use OCA\Files_Sharing\SharedStorage; |
32 | 29 | use OCA\GroupFolders\Mount\GroupFolderStorage; |
@@ -151,6 +148,21 @@ public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatch |
151 | 148 | } |
152 | 149 |
|
153 | 150 | $matches = $ruleMatcher->getFlows(false); |
| 151 | + if (empty($matches)) { |
| 152 | + return; |
| 153 | + } |
| 154 | + |
| 155 | + if (preg_match('/\$\(|`/', $node->getName())) { |
| 156 | + $this->logger->warning( |
| 157 | + 'Potentially dangerous characters in filename, skipping workflow', |
| 158 | + [ |
| 159 | + 'app' => Application::APPID, |
| 160 | + 'file' => $node->getPath(), |
| 161 | + ] |
| 162 | + ); |
| 163 | + return; |
| 164 | + } |
| 165 | + |
154 | 166 | foreach ($matches as $match) { |
155 | 167 | try { |
156 | 168 | $command = $this->buildCommand($match['operation'], $node, $eventName, $extra); |
@@ -194,21 +206,6 @@ protected function buildCommand(string $template, Node $node, string $event, arr |
194 | 206 | unset($ncRelPath); |
195 | 207 | } |
196 | 208 |
|
197 | | - if (strpos($command, '%f')) { |
198 | | - try { |
199 | | - $view = new View(); |
200 | | - if ($node instanceof FileNode) { |
201 | | - $fullPath = $view->getLocalFile($node->getPath()); |
202 | | - } |
203 | | - if (!isset($fullPath) || $fullPath === false) { |
204 | | - throw new InvalidArgumentException(); |
205 | | - } |
206 | | - $command = str_replace('%f', escapeshellarg($fullPath), $command); |
207 | | - } catch (Exception) { |
208 | | - throw new InvalidArgumentException('Could not determine full path'); |
209 | | - } |
210 | | - } |
211 | | - |
212 | 209 | if (strpos($command, '%i')) { |
213 | 210 | $nodeID = -1; |
214 | 211 | try { |
|
0 commit comments