#125_fehler_im_kontaktformular #126

Merged
muli merged 8 commits from #125_fehler_im_kontaktformular into main 2022-08-24 22:41:22 +02:00
Showing only changes of commit aebb53e5c1 - Show all commits

View File

@ -6,14 +6,13 @@ function sanitize_text(string $name, string $type) {
'text' => FILTER_SANITIZE_SPECIAL_CHARS, 'text' => FILTER_SANITIZE_SPECIAL_CHARS,
'email' => FILTER_SANITIZE_EMAIL, 'email' => FILTER_SANITIZE_EMAIL,
); );
$text = trim($text); $text = filter_var(trim($_POST[$name]), $filters[$type]);
$text = filter_var($_POST[$name], $filters[$type]);
$text = stripslashes($text); $text = stripslashes($text);
return $text; return $text;
} }
function prepare_message_body($message) { function prepare_message_body(string $message, string $name) {
// Replace HTML-Entities with actual carriage returns and line feeds // Replace HTML-Entities with actual carriage returns and line feeds
$message = str_replace("
", "\r", $message); $message = str_replace("
", "\r", $message);
$message = str_replace("
", "\n", $message); $message = str_replace("
", "\n", $message);
@ -38,7 +37,7 @@ function send_message_to_office($subject, $message, $name, $email) {
return mail( return mail(
getenv('WTF_CONTACT_TO'), getenv('WTF_CONTACT_TO'),
"=?UTF-8?B?" . base64_encode($subject) . "?=", "=?UTF-8?B?" . base64_encode($subject) . "?=",
prepare_message_body($message), prepare_message_body($message, $name),
$additional_headers = array( $additional_headers = array(
"From" => getenv('WTF_CONTACT_FROM'), "From" => getenv('WTF_CONTACT_FROM'),
"Reply-To" => $email, "Reply-To" => $email,