From 443e8d171087bdd8a96d967de846f3976c819a4b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 22 Nov 2011 00:19:57 +0100 Subject: [PATCH] Add test to avoid bad input --- htdocs/compta/facture.php | 6 ++++++ htdocs/langs/en_US/errors.lang | 1 + htdocs/langs/fr_FR/errors.lang | 1 + 3 files changed, 8 insertions(+) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 8cc637afa0d..9b4b206bd55 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -894,6 +894,12 @@ if (($action == 'addline' || $action == 'addline_predef') && $user->rights->fact { $result=0; + if ($_POST['np_price'] < 0 && $_POST["qty"] < 0) + { + $langs->load("errors"); + $mesg='
'.$langs->trans("ErrorBothFieldCantBeNegative",$langs->transnoentitiesnoconv("UnitPriceHT"),$langs->transnoentitiesnoconv("Qty")).'
'; + $result = -1 ; + } if (empty($_POST['idprod']) && $_POST["type"] < 0) { $mesg='
'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")).'
'; diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 12c9a29c11e..6cd3bdb4879 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -97,6 +97,7 @@ ErrorFailedToChangePassword=Failed to change password ErrorLoginDoesNotExists=User with login %s could not be found. ErrorLoginHasNoEmail=This user has no email address. Process aborted. ErrorBadValueForCode=Bad value for security code. Try again with new value... +ErrorBothFieldCantBeNegative=Fields %s and %s can't be both negative # Warnings WarningSafeModeOnCheckExecDir=Warning, PHP option safe_mode is on so command must be stored inside a directory declared by php parameter safe_mode_exec_dir. diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang index 71f56336a72..c7148b7f8c9 100644 --- a/htdocs/langs/fr_FR/errors.lang +++ b/htdocs/langs/fr_FR/errors.lang @@ -98,6 +98,7 @@ ErrorFailedToChangePassword=Échec de modification du mot de passe ErrorLoginDoesNotExists=Le compte utilisateur de login %s n'a pu être trouvé. ErrorLoginHasNoEmail=Cet utilisateur n'a pas d'email. Impossible de continuer. ErrorBadValueForCode=Mauvaise valeur saisie pour le code. Réessayez avec une nouvelle valeur... +ErrorBothFieldCantBeNegative=Les champs %s et %s ne peuvent être tous deux négatifs # Warnings WarningSafeModeOnCheckExecDir=Attention, l'option PHP safe_mode est active, la commande doit dont être dans un répertoire déclaré dans le paramètre php safe_mode_exec_dir.