diff --git a/htdocs/core/class/notify.class.php b/htdocs/core/class/notify.class.php index 5c9bf2ba30d..52acf042b7b 100644 --- a/htdocs/core/class/notify.class.php +++ b/htdocs/core/class/notify.class.php @@ -1232,6 +1232,7 @@ class Notify $outputlangs->loadLangs(array('main', 'other')); } } + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); complete_substitutions_array($substitutionarray, $outputlangs, $object); $subject = make_substitutions($emailTemplate->topic, $substitutionarray, $outputlangs); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index c24c61b5ab7..38f4ce1f606 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -10404,14 +10404,16 @@ function dol_eval($s, $returnvalue = 1, $hideerrors = 1, $onlysimplestring = '1' return ''; } } - if (strpos($s, '::') !== false) { + + if (!getDolGlobalString('MAIN_ALLOW_DOUBLE_COLON_IN_DOL_EVAL') && strpos($s, '::') !== false) { if ($returnvalue) { - return 'Bad string syntax to evaluate (double : char is forbidden): '.$s; + return 'Bad string syntax to evaluate (double : char is forbidden without setting MAIN_ALLOW_DOUBLE_COLON_IN_DOL_EVAL): '.$s; } else { - dol_syslog('Bad string syntax to evaluate (double : char is forbidden): '.$s, LOG_WARNING); + dol_syslog('Bad string syntax to evaluate (double : char is forbidden without setting MAIN_ALLOW_DOUBLE_COLON_IN_DOL_EVAL): '.$s, LOG_WARNING); return ''; } } + if (strpos($s, '`') !== false) { if ($returnvalue) { return 'Bad string syntax to evaluate (backtick char is forbidden): '.$s; @@ -10420,12 +10422,16 @@ function dol_eval($s, $returnvalue = 1, $hideerrors = 1, $onlysimplestring = '1' return ''; } } - if (preg_match('/[^0-9]+\.[^0-9]+/', $s)) { // We refuse . if not between 2 numbers - if ($returnvalue) { - return 'Bad string syntax to evaluate (dot char is forbidden): '.$s; - } else { - dol_syslog('Bad string syntax to evaluate (dot char is forbidden): '.$s, LOG_WARNING); - return ''; + + // Disallow also concat + if (getDolGlobalString('MAIN_DISALLOW_STRING_OBFUSCATION_IN_DOL_EVAL')) { + if (preg_match('/[^0-9]+\.[^0-9]+/', $s)) { // We refuse . if not between 2 numbers + if ($returnvalue) { + return 'Bad string syntax to evaluate (dot char is forbidden): '.$s; + } else { + dol_syslog('Bad string syntax to evaluate (dot char is forbidden): '.$s, LOG_WARNING); + return ''; + } } } diff --git a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php index 620fc2cc8c2..28ccd2c8f5c 100644 --- a/htdocs/core/modules/facture/doc/pdf_sponge.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_sponge.modules.php @@ -2176,7 +2176,7 @@ class pdf_sponge extends ModelePDFFactures $title = $outputlangs->transnoentities("InvoiceProForma"); } if ($this->situationinvoice) { - $langs->loadLangs(array("other")); + $outputlangs->loadLangs(array("other")); $title = $outputlangs->transnoentities("PDFInvoiceSituation") . " " . $outputlangs->transnoentities("NumberingShort") . $object->situation_counter . " -"; } if (getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) { diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index e67a86309bc..c36727dec79 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -298,11 +298,16 @@ if (empty($reshook)) { $payment->num_payment = $invoice->ref; if ($pay != "delayed") { - $payment->create($user); - $res = $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); - if ($res < 0) { + $result = $payment->create($user); // This set $payment->amount + if ($result < 0) { $error++; - dol_htmloutput_errors($langs->trans('ErrorNoPaymentDefined'), $payment->errors, 1); + dol_htmloutput_errors($payment->error, $payment->errors, 1); + } else { + $res = $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccount, '', ''); + if ($res < 0) { + $error++; + dol_htmloutput_errors($langs->trans('ErrorNoPaymentDefined'), $payment->errors, 1); + } } $remaintopay = $invoice->getRemainToPay(); // Recalculate remain to pay after the payment is recorded } elseif (getDolGlobalInt("TAKEPOS_DELAYED_TERMS")) { diff --git a/test/phpunit/SecurityTest.php b/test/phpunit/SecurityTest.php index 301065a6764..f9483236c54 100644 --- a/test/phpunit/SecurityTest.php +++ b/test/phpunit/SecurityTest.php @@ -1063,10 +1063,9 @@ class SecurityTest extends CommonClassTest print "result = ".$result."\n"; $this->assertEquals('Bad string syntax to evaluate: new __forbiddenstring__(\'abc\')', $result); - $result = (string) dol_eval('$a=function() { }; $a;', 1, 1, '0'); print "result5 = ".$result."\n"; - $this->assertStringContainsString('Bad string syntax to evaluate', $result); + $this->assertStringContainsString('Bad string syntax to evaluate', $result, 'The string was not detected as evil'); $result = (string) dol_eval('$a=function() { }; $a;', 1, 1, '1'); print "result6 = ".$result."\n"; @@ -1080,6 +1079,8 @@ class SecurityTest extends CommonClassTest print "result8 = ".$result."\n"; $this->assertStringContainsString('Bad string syntax to evaluate', $result); + $conf->global->MAIN_DISALLOW_STRING_OBFUSCATION_IN_DOL_EVAL = 1; + $result = (string) dol_eval('$a="test"; $$a;', 1, 0); print "result9 = ".$result."\n"; $this->assertStringContainsString('Bad string syntax to evaluate', $result);