[FIX] web: mark integer fields as invalid if the value exceeds 32 bits
When we enter an integer in a field and the value cannot be encoded in 32 bits, an error is thrown but the field is not marked as invalid Steps to reproduce: 1. Install Employee Referral 2. Go to Referrals > Configuration > Levels and create a new level 3. Add a name and an image and set the requirements to 9,999,999,999 points 4. Try to save the level, an error is thrown (in v15, a notification would inform the user the field is invalid) Solution: Throw an error in parseInteger when the value exceeds the 32 bits encoding limit Problem: PostgreSQL uses 32 bits for integers opw-3300851 closes odoo/odoo#123401 X-original-commit: c662a54606799cf3348aed84584e75d2ab6f20e5 Signed-off-by: Aaron Bohy (aab) <aab@odoo.com>
This commit is contained in:
@@ -139,6 +139,11 @@ export function parseInteger(value) {
|
||||
throw new InvalidNumberError(`"${value}" is not a correct number`);
|
||||
}
|
||||
}
|
||||
if (parsed < -2147483648 || parsed > 2147483647) {
|
||||
throw new InvalidNumberError(
|
||||
`"${value}" is out of bounds (integers should be between -2,147,483,648 and 2,147,483,647)`
|
||||
);
|
||||
}
|
||||
return parsed;
|
||||
}
|
||||
|
||||
|
||||
@@ -79,8 +79,12 @@ QUnit.module("Fields", (hooks) => {
|
||||
assert.strictEqual(parseInteger("-100"), -100);
|
||||
assert.strictEqual(parseInteger("1,000"), 1000);
|
||||
assert.strictEqual(parseInteger("1,000,000"), 1000000);
|
||||
assert.strictEqual(parseInteger("-2,147,483,648"), -2147483648);
|
||||
assert.strictEqual(parseInteger("2,147,483,647"), 2147483647);
|
||||
expectInvalidNumberError(assert, parseInteger, "1.000.000");
|
||||
expectInvalidNumberError(assert, parseInteger, "1,234.567");
|
||||
expectInvalidNumberError(assert, parseInteger, "-2,147,483,649");
|
||||
expectInvalidNumberError(assert, parseInteger, "2,147,483,648");
|
||||
|
||||
patchWithCleanup(localization, { decimalPoint: ",", thousandsSep: "." });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user