]> source.dussan.org Git - nextcloud-server.git/commitdiff
fix(ContactsStore): Sanitize user ID given to guest avatar route 43317/head
authorFerdinand Thiessen <opensource@fthiessen.de>
Sat, 3 Feb 2024 10:32:51 +0000 (11:32 +0100)
committerFerdinand Thiessen <opensource@fthiessen.de>
Sat, 3 Feb 2024 10:32:51 +0000 (11:32 +0100)
It is not allowed to use slashes within path parameters, so they would need to be encoded.
But URL encoded slashes are not suported by Apache, so instead replace slash with space.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
lib/private/Contacts/ContactsMenu/ContactsStore.php

index 1b3ef55cf203bca4b0e03e124d58489f2117aeab..2f141cbc0abbfc23d084cad82bab8939ca52e518 100644 (file)
@@ -353,9 +353,9 @@ class ContactsStore implements IContactsStore {
                                $avatar = $this->urlGenerator->linkToRouteAbsolute('core.avatar.getAvatar', ['userId' => $uid, 'size' => 64]);
                                $entry->setProperty('isUser', true);
                        } elseif (!empty($contact['FN'])) {
-                               $avatar = $this->urlGenerator->linkToRouteAbsolute('core.GuestAvatar.getAvatar', ['guestName' => $contact['FN'], 'size' => 64]);
+                               $avatar = $this->urlGenerator->linkToRouteAbsolute('core.GuestAvatar.getAvatar', ['guestName' => str_replace('/', ' ', $contact['FN']), 'size' => 64]);
                        } else {
-                               $avatar = $this->urlGenerator->linkToRouteAbsolute('core.GuestAvatar.getAvatar', ['guestName' => $uid, 'size' => 64]);
+                               $avatar = $this->urlGenerator->linkToRouteAbsolute('core.GuestAvatar.getAvatar', ['guestName' => str_replace('/', ' ', $uid), 'size' => 64]);
                        }
                        $entry->setAvatar($avatar);
                }