awful.wibox: sanitize height/width args to function new()
When both height and width arguments are provided to the function new() there is a check to see if one of them was a screen percentage, and is expected to be a string. If the user provided absolute pixels, and argument is of type number awesome will crash. Now tostring is used to sanitize the arguments during this check. Signed-off-by: Adrian C. (anrxc) <anrxc@sysphere.org> Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
b24348219e
commit
9038c5165d
|
@ -13,6 +13,7 @@ local capi =
|
||||||
client = client
|
client = client
|
||||||
}
|
}
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
|
local tostring = tostring
|
||||||
local ipairs = ipairs
|
local ipairs = ipairs
|
||||||
local table = table
|
local table = table
|
||||||
local type = type
|
local type = type
|
||||||
|
@ -226,7 +227,7 @@ function new(arg)
|
||||||
if arg.height then
|
if arg.height then
|
||||||
has_to_stretch = false
|
has_to_stretch = false
|
||||||
if arg.screen then
|
if arg.screen then
|
||||||
local hp = arg.height:match("(%d+)%%")
|
local hp = tostring(arg.height):match("(%d+)%%")
|
||||||
if hp then
|
if hp then
|
||||||
arg.height = capi.screen[arg.screen].geometry.height * hp / 100
|
arg.height = capi.screen[arg.screen].geometry.height * hp / 100
|
||||||
end
|
end
|
||||||
|
@ -237,7 +238,7 @@ function new(arg)
|
||||||
if arg.width then
|
if arg.width then
|
||||||
has_to_stretch = false
|
has_to_stretch = false
|
||||||
if arg.screen then
|
if arg.screen then
|
||||||
local wp = arg.width:match("(%d+)%%")
|
local wp = tostring(arg.width):match("(%d+)%%")
|
||||||
if wp then
|
if wp then
|
||||||
arg.width = capi.screen[arg.screen].geometry.width * wp / 100
|
arg.width = capi.screen[arg.screen].geometry.width * wp / 100
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue