Skip to content

Commit

Permalink
Merge pull request #30618 from nextcloud/backport/30609/stable22
Browse files Browse the repository at this point in the history
[stable22] Fix RequestURL check for cli commands
  • Loading branch information
CarlSchwan authored Jan 12, 2022
2 parents 51d4f30 + efe0623 commit 29a3f2c
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions apps/workflowengine/lib/Check/RequestURL.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@
use OCP\IRequest;

class RequestURL extends AbstractStringCheck {
public const CLI = 'cli';

/** @var string */
/** @var ?string */
protected $url;

/** @var IRequest */
Expand All @@ -49,7 +50,11 @@ public function __construct(IL10N $l, IRequest $request) {
* @return bool
*/
public function executeCheck($operator, $value) {
$actualValue = $this->getActualValue();
if (\OC::$CLI) {
$actualValue = $this->url = RequestURL::CLI;
} else {
$actualValue = $this->getActualValue();
}
if (in_array($operator, ['is', '!is'])) {
switch ($value) {
case 'webdav':
Expand Down Expand Up @@ -79,10 +84,10 @@ protected function getActualValue() {
return $this->url; // E.g. https://localhost/nextcloud/index.php/apps/files_texteditor/ajax/loadfile
}

/**
* @return bool
*/
protected function isWebDAVRequest() {
protected function isWebDAVRequest(): bool {
if ($this->url === RequestURL::CLI) {
return false;
}
return substr($this->request->getScriptName(), 0 - strlen('/remote.php')) === '/remote.php' && (
$this->request->getPathInfo() === '/webdav' ||
strpos($this->request->getPathInfo(), '/webdav/') === 0 ||
Expand Down

0 comments on commit 29a3f2c

Please sign in to comment.