values.slice!('-A')
keys << :chain
- # Here we generate the main hash
- keys.zip(values.scan(/"[^"]*"|\S+/).reverse) { |f, v| hash[f] = v.gsub(/"/, '') }
+ # Here we generate the main hash by scanning arguments off the values
+ # string, handling any quoted characters present in the value, and then
+ # zipping the values with the array of keys.
+ keys.zip(values.scan(/("([^"\\]|\\.)*"|\S+)/).transpose[0].reverse) do |f, v|
+ if v =~ /^".*"$/ then
+ hash[f] = v.sub(/^"(.*)"$/, '\1').gsub(/\\(\\|'|")/, '\1')
+ else
+ hash[f] = v.dup
+ end
+ end
#####################
# POST PARSE CLUDGING
:source => '192.168.0.1/32',
},
},
+ 'string_escape_sequences' => {
+ :line => '-A INPUT -m comment --comment "000 parse escaped \\"s, \\\'s, and \\\\s"',
+ :table => 'filter',
+ :params => {
+ :name => '000 parse escaped "s, \'s, and \\s',
+ },
+ },
'log_level_debug' => {
:line => '-A INPUT -m comment --comment "956 INPUT log-level" -m state --state NEW -j LOG --log-level 7',
:table => 'filter',