summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2013-11-15 02:21:34 +0000
committerTed Trask <ttrask01@yahoo.com>2013-11-15 02:23:47 +0000
commitc5eb814c8734750aaec1fd90bd4e249b2c9ef25f (patch)
tree2c759611dff2cc051b2bc7cc181aa0cb5f51e47b
parentf79712f0c81c869c3ca0af1fb93a93ff5f086402 (diff)
downloadacf-core-c5eb814c8734750aaec1fd90bd4e249b2c9ef25f.tar.bz2
acf-core-c5eb814c8734750aaec1fd90bd4e249b2c9ef25f.tar.xz
Modify authenticator-plaintext library to escape id and table before searching for it
-rw-r--r--lib/authenticator-plaintext.lua13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/authenticator-plaintext.lua b/lib/authenticator-plaintext.lua
index ecfca03..7a5dbea 100644
--- a/lib/authenticator-plaintext.lua
+++ b/lib/authenticator-plaintext.lua
@@ -10,6 +10,7 @@ create a different file for each field.
local mymodule = {}
fs = require("acf.fs")
+format = require("acf.format")
posix = require("posix")
mymodule.list_fields = function(self, tabl)
@@ -18,8 +19,8 @@ mymodule.list_fields = function(self, tabl)
end
local fields = {}
- for file in fs.find(".*"..tabl, self.conf.confdir) do
- local field = string.match(file, "([^/]*)"..tabl.."$") or ""
+ for file in fs.find(".*"..format.escapemagiccharacters(tabl), self.conf.confdir) do
+ local field = string.match(file, "([^/]*)"..format.escapemagiccharacters(tabl).."$") or ""
if fs.is_file(file) and field ~= "" then
fields[#fields + 1] = field
end
@@ -75,7 +76,7 @@ mymodule.write_entry = function(self, tabl, field, id, entry)
local passwdfilecontent = fs.read_file_as_array(passwd_path) or {}
local output = {id .. ":" .. entry}
for k,v in pairs(passwdfilecontent) do
- if not ( string.match(v, "^".. id .. "[:=]") ) and not string.match(v, "^%s*$") then
+ if not ( string.match(v, "^".. format.escapemagiccharacters(id) .. "[:=]") ) and not string.match(v, "^%s*$") then
table.insert(output, v)
end
end
@@ -92,8 +93,8 @@ mymodule.read_entry = function(self, tabl, field, id)
local passwdfilecontent = fs.read_file_as_array(passwd_path) or {}
local entry
for k,v in pairs(passwdfilecontent) do
- if string.match(v, "^".. id .. "[:=]") then
- return string.match(v, "^"..id.."[:=](.*)")
+ if string.match(v, "^".. format.escapemagiccharacters(id) .. "[:=]") then
+ return string.match(v, "^"..format.escapemagiccharacters(id).."[:=](.*)")
end
end
return nil
@@ -109,7 +110,7 @@ mymodule.delete_entry = function (self, tabl, field, id)
local passwdfilecontent = fs.read_file_as_array(passwd_path) or {}
local output = {}
for k,v in pairs(passwdfilecontent) do
- if not ( string.match(v, "^".. id .. "[:=]") ) and not string.match(v, "^%s*$") then
+ if not ( string.match(v, "^".. format.escapemagiccharacters(id) .. "[:=]") ) and not string.match(v, "^%s*$") then
table.insert(output, v)
else
result = true