From 8dace6eca5474ab838799947d08d4eca88087df9 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Tue, 28 Apr 2020 07:56:38 +0200 Subject: [PATCH] remove special characters from name when generating extrausers file add froxlor hostname to 2fa-qrcode; refs #814 Signed-off-by: Michael Kaufmann --- 2fa.php | 2 +- lib/Froxlor/Cron/System/Extrausers.php | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/2fa.php b/2fa.php index dd73110b..9bd5f2cd 100644 --- a/2fa.php +++ b/2fa.php @@ -38,7 +38,7 @@ if (AREA == 'admin') { } $success_message = ""; -$tfa = new \Froxlor\FroxlorTwoFactorAuth('Froxlor'); +$tfa = new \Froxlor\FroxlorTwoFactorAuth('Froxlor ' . Settings::Get('system.hostname')); // do the delete and then just show a success-message if ($action == 'delete') { diff --git a/lib/Froxlor/Cron/System/Extrausers.php b/lib/Froxlor/Cron/System/Extrausers.php index e837c683..74f1aea5 100644 --- a/lib/Froxlor/Cron/System/Extrausers.php +++ b/lib/Froxlor/Cron/System/Extrausers.php @@ -67,7 +67,7 @@ class Extrausers 'name' => \Froxlor\Customer\Customer::getCustomerDetail($u['customerid'], 'name'), 'company' => \Froxlor\Customer\Customer::getCustomerDetail($u['customerid'], 'company') ); - $u['comment'] = \Froxlor\User::getCorrectUserSalutation($salutation_array); + $u['comment'] = self::cleanString(\Froxlor\User::getCorrectUserSalutation($salutation_array)); if ($u['login_enabled'] != 'Y') { $u['password'] = '*'; $u['shell'] = '/bin/false'; @@ -90,4 +90,10 @@ class Extrausers $cronlog->logAction(\Froxlor\FroxlorLogger::CRON_ACTION, LOG_NOTICE, 'Error when writing ' . $type . ' file entries'); } } + + private static function cleanString($string = null) + { + $allowed = "/[^a-z0-9\\.\\-\\_\\ ]/i"; + return preg_replace($allowed, "", $string); + } }