The first thing I would like to mention is that this had been previously blocked within the SugarCRM application, and we are working diligently to ensure that the application stays secure. Secondly here are two fixes you can apply to your system to ensure that this doesn't happen again. One on the javascript level and one on the back end level. Apply one or both if you would like.
In sugar_3,js
replace the unformatNumber function with this
Code:
// format and unformat numbers
function unformatNumber(n, num_grp_sep, dec_sep) {
if(typeof num_grp_sep == 'undefined' || typeof dec_sep == 'undefined') return n;
n = n.toString();
if(n.length > 0) {
n = n.replace(new RegExp(RegExp.escape(num_grp_sep), 'g'), '').replace(new RegExp(RegExp.escape(dec_sep)), '.');
return n;
}
return '';
} For the backend fix in modules/Currencies/Currency.php replace function unformat_number($string) with
Code:
function unformat_number($string) {
static $currency = null;
if(!isset($currency)) {
global $current_user;
$currency = new Currency();
if($current_user->getPreference('currency')) $currency->retrieve($current_user->getPreference('currency'));
else $currency->retrieve('-99'); // use default if none set
}
$seps = get_number_seperators();
// remove num_grp_sep and replace decimal seperater with decimal
$string = trim(str_replace(array($seps[0], $seps[1], $currency->symbol), array('', '.', ''), $string));
preg_match('/[0-9\.]*/', $string, $string);
return trim($string[0]);
} As always try it on a dev or test environment before deploying, and if you have any issues with this let me know and I will address them as soon as possible.
Bookmarks