NOW MANAGED ON CODEBERG
Fixed LDAP_DUMP_* options when data contains binary
Dan Brown328bc88f02ad
diff --git a/app/Exceptions/JsonDebugException.php b/app/Exceptions/JsonDebugException.phpindex e8d61305e..8acc19778 100644--- a/app/Exceptions/JsonDebugException.php+++ b/app/Exceptions/JsonDebugException.php@@ -19,10 +19,13 @@ class JsonDebugException extends Exception}/**- * Covert this exception into a response.+ * Convert this exception into a response.+ * We add a manual data conversion to UTF8 to ensure any binary data is presentable as a JSON string.*/public function render(): JsonResponse{- return response()->json($this->data);+ $cleaned = mb_convert_encoding($this->data, 'UTF-8');++ return response()->json($cleaned);}}diff --git a/tests/Auth/LdapTest.php b/tests/Auth/LdapTest.phpindex 03ef926cb..078940b63 100644--- a/tests/Auth/LdapTest.php+++ b/tests/Auth/LdapTest.php@@ -615,7 +615,7 @@ class LdapTest extends TestCasepublic function test_dump_user_details_option_works(){- config()->set(['services.ldap.dump_user_details' => true]);+ config()->set(['services.ldap.dump_user_details' => true, 'services.ldap.thumbnail_attribute' => 'jpegphoto']);$this->commonLdapMocks(1, 1, 1, 1, 1);$this->mockLdap->shouldReceive('searchAndGetEntries')->times(1)@@ -623,6 +623,8 @@ class LdapTest extends TestCase->andReturn(['count' => 1, 0 => ['uid' => [$this->mockUser->name],'cn' => [$this->mockUser->name],+ // Test dumping binary data for avatar responses+ 'jpegphoto' => base64_decode('/9j/4AAQSkZJRg=='),'dn' => ['dc=test' . config('services.ldap.base_dn')],]]);