Revision ae3d4c2c
Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt
SL/Form.pm | ||
---|---|---|
1172 | 1172 |
} |
1173 | 1173 |
|
1174 | 1174 |
$amount =~ s/,//g; |
1175 |
# make shure no code wich is not a math expression ends in eval() |
|
1176 |
|
|
1177 |
$amount =~ s/\s//g; |
|
1178 |
|
|
1179 |
unless($amount =~ /^[-\+]?\d+\.?\d*([-\+\*\/][-\+]?\d+\.?\d*)*$/){ |
|
1180 |
return 0; |
|
1181 |
} |
|
1182 | 1175 |
|
1183 | 1176 |
$main::lxdebug->leave_sub(2); |
1184 | 1177 |
|
1185 |
return (eval $amount) * 1 ; |
|
1178 |
# Make sure no code wich is not a math expression ends up in eval(). |
|
1179 |
return 0 unless $amount =~ /^ [\s \d \( \) \- \+ \* \/ \. ]* $/x; |
|
1180 |
return scalar(eval($amount)) * 1 ; |
|
1186 | 1181 |
} |
1187 | 1182 |
|
1188 | 1183 |
sub round_amount { |
js/common.js | ||
---|---|---|
58 | 58 |
if(decpoint && decpoint == ','){ |
59 | 59 |
test_val = test_val.replace(/,/g, '.'); |
60 | 60 |
} |
61 |
var forbidden = test_val.match(/[^-\+\/\*\.0-9\ ]/g );
|
|
61 |
var forbidden = test_val.match(/[^\s\d\(\)\-\+\*\/\.]/g);
|
|
62 | 62 |
if (forbidden && forbidden.length > 0 ){ |
63 | 63 |
return show_alert_and_focus(input_name, wrongNumberFormat); |
64 | 64 |
} |
Auch abrufbar als: Unified diff
Berechnung in Zahlenfelder: Erlaubte Zeichen auf Klammern ausgeweitet