Update functions.lib.php

Fix #15820
Fix #15820
function price2num
add underscore in the pattern in instruction 
$amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>]/', '', $amount);
as this:
$amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>\_\-]/', '', $amount);
in order to cover some constantes cases as 20% (TX_NORMAL) or 10% (TX_REDUIT) where underscore is used.
it seems that some constantes use also "-" so I added it in the pattern.
I don't know if other characters have to be added to this pattern.
This commit is contained in:
zuiko 2021-01-14 15:00:53 +01:00 committed by GitHub
parent 727751e0c1
commit fd5948f716
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4725,7 +4725,7 @@ function price2num($amount, $rounding = '', $option = 0)
if ($option != 1) { // If not a PHP number or unknown, we change or clean format
//print 'PP'.$amount.' - '.$dec.' - '.$thousand.' - '.intval($amount).'<br>';
if (!is_numeric($amount)) {
$amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>\_]/', '', $amount);
$amount = preg_replace('/[a-zA-Z\/\\\*\(\)\<\>\_\-]/', '', $amount);
}
if ($option == 2 && $thousand == '.' && preg_match('/\.(\d\d\d)$/', (string) $amount)) { // It means the . is used as a thousand separator and string come frominput data, so 1.123 is 1123