diff --git a/mod/settings.php b/mod/settings.php index c11ac37e3a..414894ef54 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -229,7 +229,7 @@ function settings_post(App $a) notice(DI::l10n()->t('Contact CSV file upload error')); } else { $csvArray = array_map('str_getcsv', file($_FILES['importcontact-filename']['tmp_name'])); - Logger::info('Import started', ['lines' => count($csvArray)]); + Logger::notice('Import started', ['lines' => count($csvArray)]); // import contacts foreach ($csvArray as $csvRow) { // The 1st row may, or may not contain the headers of the table @@ -237,18 +237,20 @@ function settings_post(App $a) // or the handle of the account, therefore we check for either // "http" or "@" to be present in the string. // All other fields from the row will be ignored - if ((strpos($csvRow[0],'@') !== false) || (strpos($csvRow[0],'http') !== false)) { + if ((strpos($csvRow[0],'@') !== false) || in_array(parse_url($csvRow[0], PHP_URL_SCHEME), ['http', 'https'])) { Worker::add(PRIORITY_LOW, 'AddContact', $_SESSION['uid'], $csvRow[0]); + } else { + Logger::notice('Invalid account', ['url' => $csvRow[0]]); } } - Logger::info('Import done'); + Logger::notice('Import done'); info(DI::l10n()->t('Importing Contacts done')); // delete temp file unlink($_FILES['importcontact-filename']['tmp_name']); } } else { - Logger::info('Import triggered, but no import file was found.'); + Logger::notice('Import triggered, but no import file was found.'); } return; diff --git a/src/Model/Contact.php b/src/Model/Contact.php index b0b5fcc91b..c6e3a4c364 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -2821,6 +2821,9 @@ class Contact $count = 0; foreach ($urls as $url) { + if (empty($url) || !is_string($url)) { + continue; + } $contact = self::getByURL($url, false, ['id', 'updated']); if (empty($contact['id'])) { Worker::add(PRIORITY_LOW, 'AddContact', 0, $url);