summaryrefslogtreecommitdiffstats
path: root/apps/workflowengine
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-03-06 12:04:54 +0100
committerJoas Schilling <coding@schilljs.com>2017-03-06 12:04:54 +0100
commite8be73f485a43e7a293a4878388a10e06f692e97 (patch)
tree3b2541fe86031953eb11bdd6b14bd9159b0af688 /apps/workflowengine
parent15673bc6011f6a8b934e251df4ac9cff6c37c465 (diff)
downloadnextcloud-server-e8be73f485a43e7a293a4878388a10e06f692e97.tar.gz
nextcloud-server-e8be73f485a43e7a293a4878388a10e06f692e97.zip
Fix mimetype detection on public uploads for the workflow engine
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/workflowengine')
-rw-r--r--apps/workflowengine/lib/Check/FileMimeType.php21
1 files changed, 20 insertions, 1 deletions
diff --git a/apps/workflowengine/lib/Check/FileMimeType.php b/apps/workflowengine/lib/Check/FileMimeType.php
index 4a985840e60..8608fffd4e2 100644
--- a/apps/workflowengine/lib/Check/FileMimeType.php
+++ b/apps/workflowengine/lib/Check/FileMimeType.php
@@ -76,13 +76,22 @@ class FileMimeType extends AbstractStringCheck {
return $this->mimeType[$this->storage->getId()][$this->path];
}
- $this->mimeType[$this->storage->getId()][$this->path] = '';
if ($this->isWebDAVRequest()) {
if ($this->request->getMethod() === 'PUT') {
$path = $this->request->getPathInfo();
$this->mimeType[$this->storage->getId()][$this->path] = $this->mimeTypeDetector->detectPath($path);
return $this->mimeType[$this->storage->getId()][$this->path];
}
+ } else if ($this->isPublicWebDAVRequest()) {
+ if ($this->request->getMethod() === 'PUT') {
+ $path = $this->request->getPathInfo();
+ if (strpos($path, '/webdav/') === 0) {
+ $path = substr($path, strlen('/webdav'));
+ }
+ $path = $this->path . $path;
+ $this->mimeType[$this->storage->getId()][$path] = $this->mimeTypeDetector->detectPath($path);
+ return $this->mimeType[$this->storage->getId()][$path];
+ }
}
if (in_array($this->request->getMethod(), ['POST', 'PUT'])) {
@@ -159,4 +168,14 @@ class FileMimeType extends AbstractStringCheck {
strpos($this->request->getPathInfo(), '/dav/files/') === 0
);
}
+
+ /**
+ * @return bool
+ */
+ protected function isPublicWebDAVRequest() {
+ return substr($this->request->getScriptName(), 0 - strlen('/public.php')) === '/public.php' && (
+ $this->request->getPathInfo() === '/webdav' ||
+ strpos($this->request->getPathInfo(), '/webdav/') === 0
+ );
+ }
}