system-wide: fix escaping of magic chars

* fix escaping of magic lua chars (#2800)
* fix redundant second gsub line in shellstartsqescape function
* fix return value of shellstartsqescape function

Signed-off-by: Dirk Brenken <dev@brenken.org>
This commit is contained in:
Dirk Brenken 2019-06-29 19:26:07 +02:00
parent 86fd703bae
commit f73da9ca82
No known key found for this signature in database
GPG key ID: 9D71CD547BFAE684
3 changed files with 4 additions and 5 deletions

View file

@ -26,7 +26,7 @@ pwd.password = false
function pwd.write(self, section, value) function pwd.write(self, section, value)
local pass local pass
if string.match(value, "^\$%d\$.*") then if string.match(value, "^%$%d%$.*") then
pass = value pass = value
else else
local t = tonumber(nixio.getpid()*os.time()) local t = tonumber(nixio.getpid()*os.time())

View file

@ -418,7 +418,7 @@ function maxlength(val, max)
end end
function phonedigit(val) function phonedigit(val)
return (val:match("^[0-9\*#!%.]+$") ~= nil) return (val:match("^[0-9%*#!%.]+$") ~= nil)
end end
function timehhmmss(val) function timehhmmss(val)

View file

@ -207,9 +207,8 @@ end
-- handling. It may actually be a property of the getopt function -- handling. It may actually be a property of the getopt function
-- rather than the shell proper. -- rather than the shell proper.
function shellstartsqescape(value) function shellstartsqescape(value)
res, _ = string.gsub(value, "^\-", "\\-") res, _ = string.gsub(value, "^%-", "\\-")
res, _ = string.gsub(res, "^-", "\-") return shellsqescape(res)
return shellsqescape(value)
end end
-- containing the resulting substrings. The optional max parameter specifies -- containing the resulting substrings. The optional max parameter specifies