2828
2929class RequestURL extends AbstractStringCheck {
3030
31- /** @var string */
31+ const CLI = 'cli ' ;
32+
33+ /** @var ?string */
3234 protected $ url ;
3335
3436 /** @var IRequest */
@@ -49,7 +51,11 @@ public function __construct(IL10N $l, IRequest $request) {
4951 * @return bool
5052 */
5153 public function executeCheck ($ operator , $ value ) {
52- $ actualValue = $ this ->getActualValue ();
54+ if (\OC ::$ CLI ) {
55+ $ actualValue = $ this ->url = RequestURL::CLI ;
56+ } else {
57+ $ actualValue = $ this ->getActualValue ();
58+ }
5359 if (in_array ($ operator , ['is ' , '!is ' ])) {
5460 switch ($ value ) {
5561 case 'webdav ' :
@@ -63,10 +69,7 @@ public function executeCheck($operator, $value) {
6369 return $ this ->executeStringCheck ($ operator , $ value , $ actualValue );
6470 }
6571
66- /**
67- * @return string
68- */
69- protected function getActualValue () {
72+ protected function getActualValue (): string {
7073 if ($ this ->url !== null ) {
7174 return $ this ->url ;
7275 }
@@ -79,10 +82,10 @@ protected function getActualValue() {
7982 return $ this ->url ; // E.g. https://localhost/nextcloud/index.php/apps/files_texteditor/ajax/loadfile
8083 }
8184
82- /**
83- * @return bool
84- */
85- protected function isWebDAVRequest () {
85+ protected function isWebDAVRequest (): bool {
86+ if ( $ this -> url === RequestURL:: CLI ) {
87+ return false ;
88+ }
8689 return substr ($ this ->request ->getScriptName (), 0 - strlen ('/remote.php ' )) === '/remote.php ' && (
8790 $ this ->request ->getPathInfo () === '/webdav ' ||
8891 strpos ($ this ->request ->getPathInfo (), '/webdav/ ' ) === 0 ||
0 commit comments