summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/htdocs/luci-static
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2019-09-03 19:25:39 +0200
committerJo-Philipp Wich <jo@mein.io>2019-09-10 15:28:16 +0200
commit6d9a23af60f796e14dd9652d4f401db1a5ac456f (patch)
treec2196f05d7a761b5687bddb1902b9d5960f75be8 /modules/luci-base/htdocs/luci-static
parent642b8277df5c996a160d23a361593b5bc4f8eb10 (diff)
luci-base: cbi.js: fix unintended number sign overflow in format
Fixes: #3003 Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/htdocs/luci-static')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/cbi.js13
1 files changed, 7 insertions, 6 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js
index d4d61eb381..a3528fcace 100644
--- a/modules/luci-base/htdocs/luci-static/resources/cbi.js
+++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js
@@ -566,7 +566,7 @@ String.prototype.format = function()
switch(pType) {
case 'b':
- subst = (~~param || 0).toString(2);
+ subst = Math.floor(+param || 0).toString(2);
break;
case 'c':
@@ -574,11 +574,12 @@ String.prototype.format = function()
break;
case 'd':
- subst = (~~param || 0);
+ subst = Math.floor(+param || 0).toFixed(0);
break;
case 'u':
- subst = ~~Math.abs(+param || 0);
+ var n = +param || 0;
+ subst = Math.floor((n < 0) ? 0x100000000 + n : n).toFixed(0);
break;
case 'f':
@@ -588,7 +589,7 @@ String.prototype.format = function()
break;
case 'o':
- subst = (~~param || 0).toString(8);
+ subst = Math.floor(+param || 0).toString(8);
break;
case 's':
@@ -596,11 +597,11 @@ String.prototype.format = function()
break;
case 'x':
- subst = ('' + (~~param || 0).toString(16)).toLowerCase();
+ subst = Math.floor(+param || 0).toString(16).toLowerCase();
break;
case 'X':
- subst = ('' + (~~param || 0).toString(16)).toUpperCase();
+ subst = Math.floor(+param || 0).toString(16).toUpperCase();
break;
case 'h':