rules: accept rule if regexp is ok or value is equal

correct problem matching expression with - or special regexp character

Signed-off-by: Cedric GESTES <ctaf42@gmail.com>
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Cedric GESTES 2009-08-26 17:49:38 +02:00 committed by Julien Danjou
parent db10f783a6
commit cbaefeed9d
1 changed files with 4 additions and 2 deletions

View File

@ -52,8 +52,10 @@ rules = {}
function match(c, rule) function match(c, rule)
for field, value in pairs(rule) do for field, value in pairs(rule) do
if c[field] then if c[field] then
if type(c[field]) == "string" and not c[field]:match(value) then if type(c[field]) == "string" then
if not c[field]:match(value) and c[field] ~= value then
return false return false
end
elseif c[field] ~= value then elseif c[field] ~= value then
return false return false
end end