[prev in list] [next in list] [prev in thread] [next in thread]
List: smarty-general
Subject: [SMARTY] function.math bugfix
From: Mirko Buffoni <mirbuf () tin ! it>
Date: 2004-04-12 17:20:22
Message-ID: 5.1.0.14.2.20040412180056.02fc54f8 () sakura ! oddo ! it
[Download RAW message or body]
Hi friends,
I came across a bug in function math plugin:
...
foreach($params as $key => $val) {
if ($key != "equation" && $key != "format" && $key != "assign") {
// make sure value is not empty
if (strlen($val)==0) {
$smarty->trigger_error("math: parameter $key is empty");
return;
}
if (!is_numeric($val)) {
$smarty->trigger_error("math: parameter $key: is not
numeric");
return;
}
$equation = preg_replace("/\b$key\b/",$val, $equation);
}
}
...
Change to:
$equation =
preg_replace("/\b$key\b/",preg_replace("!^([\-]?)[0]+([0-9])!","\\1\\2",$val),
$equation);
I had 0-padded numbers (can be float too).
Everything it's ok but not 08 and 09 which are considered octal (i think) and
converted to 0.
So an equation like "x+1" leads to 08+1 => 1, and 09+1 => 1.
The change fixes this situation.
Mirko
--
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic