Skip to content

Commit 219044b

Browse files
authored
Merge pull request #1433 from nextcloud/enh/1423/unprefixed-base64-avatar
Add a fallback case when parsing the avatar attribute
2 parents 4aaac7a + e6880b5 commit 219044b

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

lib/Service/ProvisioningService.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,13 @@ private function setUserAvatar(string $userId, string $avatarAttribute): void {
529529
$this->logger->warning('Failed to decode base64 JPEG avatar for user ' . $userId, ['avatar_attribute' => $avatarAttribute]);
530530
return;
531531
}
532+
} else {
533+
// fallback if it's not a URL and does not have a base64 data prefix: try to decode it as base64
534+
$avatarContent = base64_decode($avatarAttribute);
535+
if ($avatarContent === false) {
536+
$this->logger->warning('Failed to decode base64 unprefixed avatar for user ' . $userId, ['avatar_attribute' => $avatarAttribute]);
537+
return;
538+
}
532539
}
533540

534541
if ($avatarContent === null || $avatarContent === '') {

0 commit comments

Comments
 (0)