Description: fix(security): Security fix for WSTG-INPV-02.
 Fix Crash / NSException where mailIdentities is invalid on init.
Bug: https://bugs.sogo.nu/view.php?id=5651

commit fe9ae12e46a151ee5989ed1f0009bb81611a46bd
Author: smizrahi <seb.mizrahi@gmail.com>
Date:   Mon Dec 5 11:45:45 2022 +0100

    fix(security): Security fix for WSTG-INPV-02. Fix NSException where tried to modify NSDictionary. Closes #5651.

diff --git a/SoObjects/SOGo/SOGoUserDefaults.m b/SoObjects/SOGo/SOGoUserDefaults.m
index 357f8ebe6..5073e29b2 100644
--- a/SoObjects/SOGo/SOGoUserDefaults.m
+++ b/SoObjects/SOGo/SOGoUserDefaults.m
@@ -805,9 +805,9 @@ NSString *SOGoPasswordRecoverySecondaryEmail = @"SecondaryEmail";
   // Remove possible XSS injection
   mailIdentities = [NSMutableArray arrayWithArray: [self arrayForKey: @"SOGoMailIdentities"]];
   for (i = 0 ; i < [mailIdentities length] ; i++) {
-    mailIdentity = [mailIdentities objectAtIndex: i];
-    if (mailIdentity && [mailIdentity objectForKey: @"fullName"] && [[self arrayForKey: @"SOGoMailIdentities"] isKindOfClass: [NSString class]]) {
-      fullName = [NSString stringWithString: [self arrayForKey: @"SOGoMailIdentities"]];
+    mailIdentity = [NSMutableDictionary dictionaryWithDictionary: [mailIdentities objectAtIndex: i]];
+    if (mailIdentity && [mailIdentity objectForKey: @"fullName"]) {
+      fullName = [NSString stringWithString: [mailIdentity objectForKey: @"fullName"]];
       if (fullName) {
         [mailIdentity setObject: [fullName stringWithoutHTMLInjection: YES] forKey: @"fullName"];
         [mailIdentities setObject: mailIdentity atIndexedSubscript: i];
