summaryrefslogtreecommitdiffstats
path: root/lib/private/Files
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-10-28 21:56:05 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2019-10-28 21:56:29 +0100
commitbc9b223e65afc2691a74b558f6756d359c6c64bf (patch)
treede8ce1403e89afe01a010d5d7df91cdc5db69499 /lib/private/Files
parent68953f7c3d765b8b1af1d7c2e8be432fafbcff34 (diff)
downloadnextcloud-server-bc9b223e65afc2691a74b558f6756d359c6c64bf.tar.gz
nextcloud-server-bc9b223e65afc2691a74b558f6756d359c6c64bf.zip
Fix DAV mimetype search
Fixes #15048 Catches the case where a full mimetype is sumbitted in the where like clause. Before we didn't catch this and it was just forwarded as is causing invalid queries. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/Files')
-rw-r--r--lib/private/Files/Cache/QuerySearchHelper.php11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/private/Files/Cache/QuerySearchHelper.php b/lib/private/Files/Cache/QuerySearchHelper.php
index ac64ba5c592..2d9d8f374f7 100644
--- a/lib/private/Files/Cache/QuerySearchHelper.php
+++ b/lib/private/Files/Cache/QuerySearchHelper.php
@@ -136,16 +136,19 @@ class QuerySearchHelper {
$type = $operator->getType();
if ($field === 'mimetype') {
if ($operator->getType() === ISearchComparison::COMPARE_EQUAL) {
- $value = $this->mimetypeLoader->getId($value);
+ $value = (int)$this->mimetypeLoader->getId($value);
} else if ($operator->getType() === ISearchComparison::COMPARE_LIKE) {
// transform "mimetype='foo/%'" to "mimepart='foo'"
if (preg_match('|(.+)/%|', $value, $matches)) {
$field = 'mimepart';
- $value = $this->mimetypeLoader->getId($matches[1]);
+ $value = (int)$this->mimetypeLoader->getId($matches[1]);
$type = ISearchComparison::COMPARE_EQUAL;
- }
- if (strpos($value, '%') !== false) {
+ } else if (strpos($value, '%') !== false) {
throw new \InvalidArgumentException('Unsupported query value for mimetype: ' . $value . ', only values in the format "mime/type" or "mime/%" are supported');
+ } else {
+ $field = 'mimetype';
+ $value = (int)$this->mimetypeLoader->getId($value);
+ $type = ISearchComparison::COMPARE_EQUAL;
}
}
} else if ($field === 'favorite') {