diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2025-03-19 19:07:28 +0100 |
---|---|---|
committer | Andy Scherzinger <info@andy-scherzinger.de> | 2025-04-27 23:05:07 +0200 |
commit | e33fcfddc1a27917df7f6a2d2034e90ce3b121b0 (patch) | |
tree | 19bd28cdc57db346083137b8cc3171cc67f33698 | |
parent | 5862d5aea146b8f2a88e1c7110869dec1d1e9f3a (diff) | |
download | nextcloud-server-fix/search-cast.tar.gz nextcloud-server-fix/search-cast.zip |
fix(dav): throw invalid argument when property type does not matchfix/search-cast
* Resolves https://github.com/nextcloud/server/issues/49972
Currently a TypeError is thrown when casting fails,
this lead to a HTTP 500 error. Instead throw a proper
InvalidArgumentError so the user receives a HTTP 400.
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
-rw-r--r-- | apps/dav/lib/Files/FileSearchBackend.php | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/apps/dav/lib/Files/FileSearchBackend.php b/apps/dav/lib/Files/FileSearchBackend.php index 1b785962112..ace367e4490 100644 --- a/apps/dav/lib/Files/FileSearchBackend.php +++ b/apps/dav/lib/Files/FileSearchBackend.php @@ -422,10 +422,16 @@ class FileSearchBackend implements ISearchBackend { $field = $this->mapPropertyNameToColumn($property); } + try { + $castedValue = $this->castValue($property, $value ?? ''); + } catch (\Error $e) { + throw new \InvalidArgumentException('Invalid property value for ' . $property->name, previous: $e); + } + return new SearchComparison( $trimmedType, $field, - $this->castValue($property, $value ?? ''), + $castedValue, $extra ?? '' ); |