From 903dabfa6c2ec323ae7edc036789629f2a799ff7 Mon Sep 17 00:00:00 2001 From: hargut Date: Mon, 19 Sep 2016 16:54:58 +0200 Subject: [PATCH] Fix e-mail attachment handling / conversion & allow local emails to be valid (#1921) * Enable local email addresses to be valid. E.g required for local Fax submission. * Fix filenames & allow spaces in filenames. * Fix attachment file names. * Revert "Fix filenames & allow spaces in filenames." This reverts commit 0908f42cc72e64dfa4fc44d424a7584da757e6be. See commit ecf490ff79a460477e9e4510d57e4fed7951eca2 for the proper fix. --- app/fax/fax_send.php | 5 +++++ resources/functions.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/fax/fax_send.php b/app/fax/fax_send.php index 83dd0cee8f..5fa789c125 100644 --- a/app/fax/fax_send.php +++ b/app/fax/fax_send.php @@ -346,6 +346,11 @@ function fax_split_dtmf(&$fax_number, &$fax_dtmf){ $fax_name = str_replace("+", "_", $fax_name); $fax_name = str_replace("=", "_", $fax_name); + + $attachment_file_name = $_files['name'][$index]; + rename($dir_fax_temp.'/'.$attachment_file_name, $dir_fax_temp.'/'.$fax_name.'.'.$fax_file_extension); + unset($attachment_file_name); + if (!$included) { //move uploaded file move_uploaded_file($_files['tmp_name'][$index], $dir_fax_temp.'/'.$fax_name.'.'.$fax_file_extension); diff --git a/resources/functions.php b/resources/functions.php index f17eda2a25..6c09d8c65b 100644 --- a/resources/functions.php +++ b/resources/functions.php @@ -1101,7 +1101,7 @@ function number_pad($number,$n) { // validate email address syntax if(!function_exists('valid_email')) { function valid_email($email) { - $regex = '/^[A-z0-9][\w.-]*@[A-z0-9][\w\-\.]+\.[A-z0-9]{2,6}$/'; + $regex = '/^[A-z0-9][\w.-]*@[A-z0-9][\w\-\.]+(\.[A-z0-9]{2,6})?$/'; if ($email != "" && preg_match($regex, $email) == 1) { return true; // email address has valid syntax }