libs/sys: don't convert searched target to uppercase in IptParser, breaks searches...
[project/luci.git] / libs / sys / luasrc / sys / iptparser.lua
index 338fb7d..84589e5 100644 (file)
@@ -19,7 +19,7 @@ luci.util   = require "luci.util"
 luci.sys    = require "luci.sys"
 luci.ip     = require "luci.ip"
 
-local tonumber, ipairs = tonumber, ipairs
+local tonumber, ipairs, table = tonumber, ipairs, table
 
 --- LuCI iptables parser and query library
 -- @cstyle     instance
@@ -122,7 +122,7 @@ function IptParser.find( self, args )
 
                -- match target
                if not ( match == true and (
-                       not args.target or args.target:upper() == rule.target
+                       not args.target or args.target == rule.target
                ) ) then
                        match = false
                end
@@ -279,6 +279,11 @@ function IptParser._parse_rules( self )
                                        local rule_parts   = luci.util.split( rule, "%s+", nil, true )
                                        local rule_details = { }
 
+                                       -- cope with rules that have no target assigned
+                                       if rule:match("^%d+%s+%d+%s+%d+%s%s") then
+                                               table.insert(rule_parts, 4, nil)
+                                       end
+
                                        rule_details["table"]       = tbl
                                        rule_details["chain"]       = self._chain
                                        rule_details["index"]       = tonumber(rule_parts[1])