mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-02-04 23:15:48 +01:00
Fix numeric option value validation for "".
Number("") => 0, Number("077") => 77, parseInt("008") => 0 etc.
--HG--
extra : transplant_source : %5B%A2%EC%06%BB%85A%C7%D3%B5%7E%B5%91f%9B1%8F%D3%3D%98
This commit is contained in:
@@ -340,10 +340,11 @@ Option.prototype = {
|
||||
break;
|
||||
|
||||
case "number":
|
||||
let value = Number(values); // deduce radix
|
||||
// TODO: support floats? Validators need updating.
|
||||
if (!/^[+-]?(?:0x[0-9a-f]+|0[0-7]+|0|[1-9]\d*)$/i.test(values))
|
||||
return "E521: Number required after := " + this.name + "=" + values;
|
||||
|
||||
if (isNaN(value) || value != parseInt(value))
|
||||
return "E521: Number required";
|
||||
let value = parseInt(values/* deduce radix */);
|
||||
|
||||
switch (operator)
|
||||
{
|
||||
@@ -411,7 +412,7 @@ Option.prototype = {
|
||||
break;
|
||||
|
||||
default:
|
||||
return "E685: Internal error: option type `" + option.type + "' not supported";
|
||||
return "E685: Internal error: option type `" + this.type + "' not supported";
|
||||
}
|
||||
|
||||
if (newValue == null)
|
||||
|
||||
Reference in New Issue
Block a user