Skip to content

Commit

Permalink
fix(#659): validate math expressions using regex
Browse files Browse the repository at this point in the history
  • Loading branch information
vomikan committed Mar 16, 2016
1 parent e601c4e commit caded8b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/model/Model_Currency.cpp
Expand Up @@ -175,15 +175,15 @@ wxString Model_Currency::toString(double value, const Data* currency, int precis
const wxString Model_Currency::fromString2Default(const wxString &s, const Data* currency)
{
wxString str = s;
str.Trim();
str.Replace(" ", "");
if (currency)
{
if (!currency->GROUP_SEPARATOR.empty())
str.Replace(currency->GROUP_SEPARATOR, "");
if (!currency->DECIMAL_POINT.empty())
str.Replace(currency->DECIMAL_POINT, wxNumberFormatter::GetDecimalSeparator());
}
const Data* c = currency ? currency : Model_Currency::GetBaseCurrency();
if (!c->GROUP_SEPARATOR.empty())
str.Replace(currency->GROUP_SEPARATOR, "");
if (!c->DECIMAL_POINT.empty())
str.Replace(currency->DECIMAL_POINT, wxNumberFormatter::GetDecimalSeparator());

wxRegEx pattern(R"([^0-9.,+-\/\*\(\)])");
pattern.ReplaceAll(&str, "");

return str;
}

Expand Down

0 comments on commit caded8b

Please sign in to comment.