Mercurial > prosody-modules
comparison mod_firewall/mod_firewall.lua @ 998:6fdcebbd2284
mod_firewall: Fix conditions with spaces
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 07 May 2013 10:32:48 +0100 |
| parents | 37af655ca575 |
| children | 197af8440ffb |
comparison
equal
deleted
inserted
replaced
| 997:69dd4e4e54a2 | 998:6fdcebbd2284 |
|---|---|
| 238 if condition:match("%f[%w]NOT%f[^%w]") then | 238 if condition:match("%f[%w]NOT%f[^%w]") then |
| 239 local s, e = condition:match("%f[%w]()NOT()%f[^%w]"); | 239 local s, e = condition:match("%f[%w]()NOT()%f[^%w]"); |
| 240 condition = (condition:sub(1,s-1)..condition:sub(e+1, -1)):match("^%s*(.-)%s*$"); | 240 condition = (condition:sub(1,s-1)..condition:sub(e+1, -1)):match("^%s*(.-)%s*$"); |
| 241 negated = true; | 241 negated = true; |
| 242 end | 242 end |
| 243 condition = condition:gsub(" ", ""); | 243 condition = condition:gsub(" ", "_"); |
| 244 if not condition_handlers[condition] then | 244 if not condition_handlers[condition] then |
| 245 return nil, ("Unknown condition on line %d: %s"):format(line_no, condition); | 245 return nil, ("Unknown condition on line %d: %s"):format(line_no, (condition:gsub("_", " "))); |
| 246 end | 246 end |
| 247 -- Get the code for this condition | 247 -- Get the code for this condition |
| 248 local ok, condition_code, condition_deps = pcall(condition_handlers[condition], line:match(":%s?(.+)$")); | 248 local ok, condition_code, condition_deps = pcall(condition_handlers[condition], line:match(":%s?(.+)$")); |
| 249 if not ok then | 249 if not ok then |
| 250 return nil, errmsg(condition_code); | 250 return nil, errmsg(condition_code); |
