From b40c40482828da914f33bde2053e13bfa2082d0d Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Sat, 28 Mar 2026 20:53:49 -0400 Subject: [PATCH] fix: ldap_get_entries returns raw binary, remove incorrect base64 decode Co-Authored-By: Claude Sonnet 4.6 --- api/user_avatar.php | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/api/user_avatar.php b/api/user_avatar.php index 44daa36..a472a30 100644 --- a/api/user_avatar.php +++ b/api/user_avatar.php @@ -130,17 +130,8 @@ try { $entries = ldap_get_entries($ldap, $search); if ($entries['count'] > 0 && !empty($entries[0]['avatar'][0])) { - // lldap stores the avatar as a base64-encoded string in the LDAP attribute - $avatarRaw = $entries[0]['avatar'][0]; - // ldap_get_entries already decodes binary attributes; but lldap stores - // the avatar as a base64 string within the attribute value itself. - // Detect: if it starts with /9j/ (JPEG magic in base64) decode it. - if (substr($avatarRaw, 0, 4) === '/9j/') { - $avatarData = base64_decode($avatarRaw); - } else { - // Raw binary JPEG (starts with FF D8) - $avatarData = $avatarRaw; - } + // ldap_get_entries() returns the attribute value as raw binary. + $avatarData = $entries[0]['avatar'][0]; } ldap_unbind($ldap);