diff --git a/facteur_fonctions.php b/facteur_fonctions.php index 14cffbe..33d7929 100644 --- a/facteur_fonctions.php +++ b/facteur_fonctions.php @@ -118,7 +118,7 @@ function facteur_formulaire_fond($flux) { $url = generer_url_ecrire('configurer_facteur'); $ajout = '

'._T('facteur:message_identite_email', array('url' => $url, 'email' => $email)).'

'; if (preg_match(",<(div|li) [^>]*class=[\"']editer editer_email_webmaster.*>,Uims", $flux['data'], $match)) { - $p = strpos($flux['data'], $match[0]); + $p = strpos($flux['data'], (string) $match[0]); $p = strpos($flux['data'], " $file, - 'nom' => $doc['titre'] ? $doc['titre'] : basename($doc['fichier']), + 'nom' => $doc['titre'] ?: basename($doc['fichier']), 'mime' => $mime, ]; break 2; diff --git a/inc/envoyer_mail.php b/inc/envoyer_mail.php index 8d45152..67a132f 100644 --- a/inc/envoyer_mail.php +++ b/inc/envoyer_mail.php @@ -92,6 +92,7 @@ function facteur_extraire_sujet($message_html, $message_texte = '') { * @throws Exception */ function inc_envoyer_mail($destinataire, $sujet, $message, $from = '', $headers = '') { + $nom_repondre_a = null; $message_html = ''; $message_texte = ''; $nom_envoyeur = $cc = $bcc = $repondre_a = ''; @@ -102,17 +103,17 @@ function inc_envoyer_mail($destinataire, $sujet, $message, $from = '', $headers // avec entrees possible : html, texte, pieces_jointes, nom_envoyeur, ... if (is_array($message)) { // si on fournit un $message['html'] deliberemment vide, c'est qu'on n'en veut pas, et donc on restera au format texte - $message_html = isset($message['html']) ? ($message['html'] ? $message['html'] : ' ') : ''; + $message_html = isset($message['html']) ? ($message['html'] ?: ' ') : ''; $message_texte = isset($message['texte']) ? nettoyer_caracteres_mail($message['texte']) : ''; - $pieces_jointes = isset($message['pieces_jointes']) ? $message['pieces_jointes'] : []; - $nom_envoyeur = isset($message['nom_envoyeur']) ? $message['nom_envoyeur'] : ''; - $from = isset($message['from']) ? $message['from'] : $from; - $cc = isset($message['cc']) ? $message['cc'] : ''; - $bcc = isset($message['bcc']) ? $message['bcc'] : ''; - $repondre_a = isset($message['repondre_a']) ? $message['repondre_a'] : ''; - $nom_repondre_a = isset($message['nom_repondre_a']) ? $message['nom_repondre_a'] : ''; - $adresse_erreur = isset($message['adresse_erreur']) ? $message['adresse_erreur'] : ''; - $headers = isset($message['headers']) ? $message['headers'] : $headers; + $pieces_jointes = $message['pieces_jointes'] ?? []; + $nom_envoyeur = $message['nom_envoyeur'] ?? ''; + $from = $message['from'] ?? $from; + $cc = $message['cc'] ?? ''; + $bcc = $message['bcc'] ?? ''; + $repondre_a = $message['repondre_a'] ?? ''; + $nom_repondre_a = $message['nom_repondre_a'] ?? ''; + $adresse_erreur = $message['adresse_erreur'] ?? ''; + $headers = $message['headers'] ?? $headers; if (is_string($headers)) { $headers = array_map('trim', explode("\n", $headers)); $headers = array_filter($headers); @@ -303,18 +304,18 @@ function inc_envoyer_mail($destinataire, $sujet, $message, $from = '', $headers } // S'il y a des pièces jointes on les ajoute proprement - if (count($pieces_jointes)) { + if (is_countable($pieces_jointes) ? count($pieces_jointes) : 0) { foreach ($pieces_jointes as $piece) { if (!empty($piece['chemin']) and file_exists($piece['chemin'])) { $facteur->AddAttachment( $piece['chemin'], - isset($piece['nom']) ? $piece['nom'] : '', + $piece['nom'] ?? '', (isset($piece['encodage']) and in_array($piece['encodage'], ['base64', '7bit', '8bit', 'binary', 'quoted-printable'])) ? $piece['encodage'] : 'base64', - isset($piece['mime']) ? $piece['mime'] : Facteur::_mime_types(pathinfo($piece['chemin'], PATHINFO_EXTENSION)) + $piece['mime'] ?? Facteur::_mime_types(pathinfo($piece['chemin'], PATHINFO_EXTENSION)) ); } else { - spip_log('Piece jointe manquante ignoree : ' . json_encode($piece), 'facteur' . _LOG_ERREUR); + spip_log('Piece jointe manquante ignoree : ' . json_encode($piece, JSON_THROW_ON_ERROR), 'facteur' . _LOG_ERREUR); } } } diff --git a/inc/facteur_envoyer_alerte_fail.php b/inc/facteur_envoyer_alerte_fail.php index 28e9acc..10a43da 100644 --- a/inc/facteur_envoyer_alerte_fail.php +++ b/inc/facteur_envoyer_alerte_fail.php @@ -22,7 +22,7 @@ function inc_facteur_envoyer_alerte_fail_dist($function, $args, $include = null) if (is_string($args)) { $args = unserialize($args); if ($args === false) { - spip_log('sendFailAlert: arguments errones ' . json_encode([$function, $args, $include]), 'facteur' . _LOG_ERREUR); + spip_log('sendFailAlert: arguments errones ' . json_encode([$function, $args, $include], JSON_THROW_ON_ERROR), 'facteur' . _LOG_ERREUR); $args = []; } } @@ -39,11 +39,11 @@ function inc_facteur_envoyer_alerte_fail_dist($function, $args, $include = null) } if (!function_exists($function)) { - spip_log("sendFailAlert: fonction $function ($include) inexistante " . json_encode([$function, $args, $include]), 'facteur' . _LOG_ERREUR); + spip_log("sendFailAlert: fonction $function ($include) inexistante " . json_encode([$function, $args, $include], JSON_THROW_ON_ERROR), 'facteur' . _LOG_ERREUR); return false; } - $traceargs = md5(json_encode($args)); + $traceargs = md5(json_encode($args, JSON_THROW_ON_ERROR)); spip_log("sendFailAlert: $function([$traceargs]) start", 'facteur'); $res = call_user_func_array($function, $args); spip_log("sendFailAlert: $function([$traceargs]) end", 'facteur');