diff options
-rw-r--r-- | lib/private/Notification/Notification.php | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/private/Notification/Notification.php b/lib/private/Notification/Notification.php index 9610a2d2a12..1ced034d7c6 100644 --- a/lib/private/Notification/Notification.php +++ b/lib/private/Notification/Notification.php @@ -302,17 +302,23 @@ class Notification implements INotification { return $this; } + /** + * @throws \InvalidArgumentException if a parameter has no name + */ private function richToParsed(string $message, array $parameters): string { $placeholders = []; $replacements = []; foreach ($parameters as $placeholder => $parameter) { $placeholders[] = '{' . $placeholder . '}'; + if (!isset($parameter['name']) || !is_string($parameter['name'])) { + throw new \InvalidArgumentException('Invalid rich object, name field is missing'); + } if (($parameter['type'] ?? '') === 'user') { - $replacements[] = '@' . $parameter['name'] ?? 'invalid-user'; + $replacements[] = '@' . $parameter['name']; } elseif (($parameter['type'] ?? '') === 'file') { - $replacements[] = $parameter['path'] ?? $parameter['name'] ?? 'invalid-file'; + $replacements[] = $parameter['path'] ?? $parameter['name']; } else { - $replacements[] = $parameter['name'] ?? 'invalid-object'; + $replacements[] = $parameter['name']; } } return str_replace($placeholders, $replacements, $message); |