summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRoeland Jago Douma <rullzer@users.noreply.github.com>2017-03-08 08:55:33 +0100
committerGitHub <noreply@github.com>2017-03-08 08:55:33 +0100
commitabecae2388fdb470e201cf74dccec416c57d512f (patch)
tree87c402808a68a45466c679c4447979be068b0693 /apps
parent98c56f9adb2189aab118ee03f2aef28c143f93c2 (diff)
parent76e52eb2f6ee345879125b55515983484c45fb3d (diff)
downloadnextcloud-server-abecae2388fdb470e201cf74dccec416c57d512f.tar.gz
nextcloud-server-abecae2388fdb470e201cf74dccec416c57d512f.zip
Merge pull request #3725 from nextcloud/issue-fac-55-mimetype-detection-on-public-uploads
Fix mimetype detection on public uploads for the workflow engine
Diffstat (limited to 'apps')
-rw-r--r--apps/workflowengine/lib/AppInfo/Application.php2
-rw-r--r--apps/workflowengine/lib/Check/FileMimeType.php21
2 files changed, 22 insertions, 1 deletions
diff --git a/apps/workflowengine/lib/AppInfo/Application.php b/apps/workflowengine/lib/AppInfo/Application.php
index e968b40612f..28e32092419 100644
--- a/apps/workflowengine/lib/AppInfo/Application.php
+++ b/apps/workflowengine/lib/AppInfo/Application.php
@@ -48,6 +48,8 @@ class Application extends \OCP\AppFramework\App {
]);
script('core', [
+ 'files/fileinfo',
+ 'files/client',
'oc-backbone-webdav',
'systemtags/systemtags',
'systemtags/systemtagmodel',
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
+ );
+ }
}