@@ -320,6 +320,13 @@ protected function importAppsSettings(IUser $user,
320320
321321 $ data = json_decode ($ importSource ->getFileContents ('settings.json ' ), true , 512 , JSON_THROW_ON_ERROR );
322322
323+ if (isset ($ data ['settings ' ]['email ' ]) && $ user ->canChangeEmail ()) {
324+ $ value = mb_strtolower (trim ($ data ['settings ' ]['email ' ]));
325+ if (filter_var ($ value , FILTER_VALIDATE_EMAIL ) || $ value === '' ) {
326+ $ user ->setSystemEMailAddress ($ value );
327+ }
328+ }
329+
323330 if (interface_exists (IUserConfig::class)) {
324331 /*
325332 * Starting with 32, we have to use the correct type
@@ -329,6 +336,9 @@ protected function importAppsSettings(IUser $user,
329336 $ userId = $ user ->getUID ();
330337 foreach ($ data as $ app => $ values ) {
331338 foreach ($ values as $ key => $ value ) {
339+ if (!$ this ->isAppSettingImportAllowed ($ app , $ key )) {
340+ continue ;
341+ }
332342 try {
333343 $ type = $ userConfig ->getValueType ($ userId , $ app , (string )$ key );
334344 } catch (UnknownKeyException ) {
@@ -368,12 +378,102 @@ protected function importAppsSettings(IUser $user,
368378 } else {
369379 foreach ($ data as $ app => $ values ) {
370380 foreach ($ values as $ key => $ value ) {
381+ if (!$ this ->isAppSettingImportAllowed ($ app , $ key )) {
382+ continue ;
383+ }
371384 $ this ->config ->setUserValue ($ user ->getUID (), $ app , $ key , $ value );
372385 }
373386 }
374387 }
375388 }
376389
390+ private function isAppSettingImportAllowed (string $ appid , string $ key ): bool {
391+ $ allowedKeys = [
392+ 'calendar ' => [
393+ 'currentView ' ,
394+ 'defaultReminder ' ,
395+ 'eventLimit ' ,
396+ 'firstRun ' ,
397+ 'showTasks ' ,
398+ 'showWeekNr ' ,
399+ 'showWeekends ' ,
400+ 'skipPopover ' ,
401+ 'slotDuration ' ,
402+ 'tasksSidebar ' ,
403+ 'timezone ' ,
404+ ],
405+ 'collectives ' => ['user_folder ' ],
406+ 'contacts ' => ['enableSocialSync ' ],
407+ 'core ' => [
408+ 'apporder ' ,
409+ 'first_day_of_week ' ,
410+ 'lang ' ,
411+ 'locale ' ,
412+ 'templateDirectory ' ,
413+ 'timezone ' ,
414+ 'whatsNewLastRead ' ,
415+ ],
416+ 'dashboard ' => ['firstRun ' ,'layout ' ,'statuses ' ],
417+ 'dav ' => ['attachmentsFolder ' ,'generateBirthdayCalendar ' ,'user_status_automation ' ],
418+ 'end_to_end_encryption ' => ['e2eeInBrowserEnabled ' ],
419+ 'files ' => [
420+ 'crop_image_previews ' ,
421+ 'default_view ' ,
422+ 'file_sorting ' ,
423+ 'file_sorting_direction ' ,
424+ 'files_views_configs ' ,
425+ 'folder_tree ' ,
426+ 'grid_view ' ,
427+ 'show_Quick_Access ' ,
428+ 'show_dialog_deletion ' ,
429+ 'show_dialog_file_extension ' ,
430+ 'show_favorites ' ,
431+ 'show_files_extensions ' ,
432+ 'show_grid,show_hidden ' ,
433+ 'show_mime_column ' ,
434+ 'show_shareoverview ' ,
435+ 'show_sharing_menu ' ,
436+ 'sort_favorites_first ' ,
437+ 'sort_folders_first ' ,
438+ ],
439+ 'files_sharing ' => [
440+ 'default_accept ' ,
441+ 'share_folder ' ,
442+ ],
443+ 'firstrunwizard ' => ['apphint ' ,'show ' ],
444+ 'notifications ' => ['sound_notification ' ,'sound_talk ' ],
445+ 'photos ' => ['croppedLayout ' ,'photosLocation ' ,'photosSourceFolders ' ],
446+ 'recommendations ' => ['enabled ' ],
447+ 'systemtags ' => ['last_used ' ],
448+ 'text ' => ['is_full_width_editor ' ,'workspace_enabled ' ],
449+ 'theming ' => [
450+ 'background ' ,
451+ 'backgroundVersion ' ,
452+ 'background_color ' ,
453+ 'background_image ' ,
454+ 'enabled-themes ' ,
455+ 'force_enable_blur_filter ' ,
456+ 'primary_color ' ,
457+ 'shortcuts_disabled ' ,
458+ ],
459+ 'twofactor_nextcloud_notification ' => ['enabled ' ],
460+ 'weather_status ' => ['address ' ,'altitude ' ,'favorites ' ,'lat ' ,'lon ' ,'mode ' ],
461+ 'whiteboard ' => ['recording_auto_upload_on_disconnect ' ],
462+ ];
463+ if (isset ($ allowedKeys [$ appid ]) && in_array ($ key , $ allowedKeys [$ appid ])) {
464+ return true ;
465+ }
466+ if ($ appid === 'activity ' ) {
467+ if (str_starts_with ($ key , 'notify_ ' )) {
468+ return true ;
469+ }
470+ if (in_array ($ key , ['configured ' ])) {
471+ return true ;
472+ }
473+ }
474+ return false ;
475+ }
476+
377477 /**
378478 * @param UserExport|UserImport $job
379479 *
0 commit comments