diff options
author | Jo-Philipp Wich <jo@mein.io> | 2019-06-06 21:06:25 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2019-07-07 15:36:26 +0200 |
commit | 0bcb9f9f1d5f30a0a06584ddf4956d754c705c9d (patch) | |
tree | 753cb34bc60c6461286c609b7e263fc847dfe2e1 /modules/luci-base | |
parent | 0539e7f6b9b51b5121a76082d82d3f442695f400 (diff) |
luci-base: cbi.js: fix number rounding in string.format()
Ensure that patterns like %d, %x, %o or %b properly truncate their
operands to whole integers.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base')
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/cbi.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index 701de0386b..d4d61eb381 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 = (~~param || 0).toString(2); break; case 'c': @@ -574,7 +574,7 @@ String.prototype.format = function() break; case 'd': - subst = ~~(+param || 0); + subst = (~~param || 0); break; case 'u': @@ -588,7 +588,7 @@ String.prototype.format = function() break; case 'o': - subst = (+param || 0).toString(8); + subst = (~~param || 0).toString(8); break; case 's': @@ -596,11 +596,11 @@ String.prototype.format = function() break; case 'x': - subst = ('' + (+param || 0).toString(16)).toLowerCase(); + subst = ('' + (~~param || 0).toString(16)).toLowerCase(); break; case 'X': - subst = ('' + (+param || 0).toString(16)).toUpperCase(); + subst = ('' + (~~param || 0).toString(16)).toUpperCase(); break; case 'h': |