From 04ff6cf758206fe08383b3e06049377c32332e3d Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Wed, 18 Sep 2024 16:23:24 +0200 Subject: [PATCH 1/2] Fixed email header bug which would become a major issue with PHP8 --- application/Emailnotification/Emailnotification.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/application/Emailnotification/Emailnotification.php b/application/Emailnotification/Emailnotification.php index 1fa645924..491567bf3 100644 --- a/application/Emailnotification/Emailnotification.php +++ b/application/Emailnotification/Emailnotification.php @@ -122,6 +122,18 @@ class Emailnotification { //$log->debug(print_r($headers, true)); $mail =& Mail::factory('mail', ["-f ".$this->email_from]); + /* + * PHP 8's mail() function now outputs proper line endings in headers (CRLF instead of LF). + * Mail_mail < 2.0 would detect a unix system and change the headers line ending to LF. + * On Mail submission to Exim (via sendmail), mail() adds its own headers first with CRLF line ending, + * making Exim treat every subsequent header's LF as an invalid line ending, adding a whitespace after the LF, + * making all our custom headers into one long header. + * + * See: https://www.exim.org/exim-html-current/doc/html/spec_html/ch-message_processing.html#SECTlineendings + * + * So we force CRLF line endings for headers here. + */ + $mail->sep = "\r\n"; $mail->send($this->email_to, $headers, $body); } From 0cdc1cbd127a963f8aaef0f94e57ef59cb85694d Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Fri, 20 Sep 2024 13:06:59 +0200 Subject: [PATCH 2/2] Fixed price with comma in PreorderApi submitPreorder() --- application/Api/v1/PreorderApicontroller.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/application/Api/v1/PreorderApicontroller.php b/application/Api/v1/PreorderApicontroller.php index afa0f4aa0..02725889e 100644 --- a/application/Api/v1/PreorderApicontroller.php +++ b/application/Api/v1/PreorderApicontroller.php @@ -830,8 +830,14 @@ class PreorderApicontroller extends mfBaseApicontroller { //$preorder_data['price_setup'] = round($product->price_setup - (($product->price_setup) / 100) * TT_PREORDER_DISCOUNT_BUSINESS); $preorder_data['price_setup'] = ($product->attributes["presales_setup_price_business"]->value) ? $product->attributes["presales_setup_price_business"]->value : $product->price_setup; } - + + if($preorder_data['price_setup']) { + $preorder_data['price_setup'] = str_replace(',', '.', $preorder_data['price_setup']); + } } + + + /* * get customer data @@ -1021,6 +1027,8 @@ class PreorderApicontroller extends mfBaseApicontroller { } if(!$preorder_id || !$preorder->ucode) { + $err_id = uniqid('err'); + $this->log->error(__METHOD__.": [$err_id] Error saving Preorder"); if($unit_changed) $unit->rollbackTransaction(); return mfResponse::InternalServerError(); }