Skip to content

Commit e33fcfd

Browse files
susnuxAndyScherzinger
authored andcommitted
fix(dav): throw invalid argument when property type does not match
* Resolves #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>
1 parent 5862d5a commit e33fcfd

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

apps/dav/lib/Files/FileSearchBackend.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,10 +422,16 @@ private function transformSearchOperation(Operator $operator) {
422422
$field = $this->mapPropertyNameToColumn($property);
423423
}
424424

425+
try {
426+
$castedValue = $this->castValue($property, $value ?? '');
427+
} catch (\Error $e) {
428+
throw new \InvalidArgumentException('Invalid property value for ' . $property->name, previous: $e);
429+
}
430+
425431
return new SearchComparison(
426432
$trimmedType,
427433
$field,
428-
$this->castValue($property, $value ?? ''),
434+
$castedValue,
429435
$extra ?? ''
430436
);
431437

0 commit comments

Comments
 (0)