Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 0cd51f70

Von Moritz Bunkus vor etwa 8 Jahren hinzugefügt

  • ID 0cd51f70d2676569387f5f6a9047eb9553fea708
  • Vorgänger 3ad2bb35
  • Nachfolger 36d1d6a4

kivi.parse_amount: bei ungültigen Zeichen 0 zurückgeben

Es werden nun nur noch mathematische Zeichen erlaubt.

Unterschiede anzeigen:

js/kivi.js
amount = amount.replace(/[\',]/g, "")
// Make sure no code wich is not a math expression ends up in eval().
if (!amount.match(/^[0-9 ()\-+*/.]*$/))
return 0;
/* jshint -W061 */
return eval(amount);
};
js/t/kivi/parse_amount.js
assert.equal(kivi.parse_amount('0123456789'), 123456789, '0123456789');
assert.equal(kivi.parse_amount('000123456789'), 123456789, '000123456789');
});
QUnit.test("kivi.parse_amount function German number style with thousand separator & contains invalid characters", function( assert ) {
kivi.setup_formats({ numbers: '1.000,00' });
assert.equal(kivi.parse_amount('iuh !@#$% 10,00'), 0, 'iuh !@#$% 10,00');
});

Auch abrufbar als: Unified diff