mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 06:37:19 -04:00
Fix for LOGSTASH-624: allow escaped spaces in key or value
This commit is contained in:
parent
e0da16cbf7
commit
e0b09f075e
2 changed files with 14 additions and 1 deletions
|
@ -96,7 +96,7 @@ class LogStash::Filters::KV < LogStash::Filters::Base
|
|||
if !event =~ /[@field_split]/
|
||||
return kv_keys
|
||||
end
|
||||
scan_re = Regexp.new("([^"+@field_split+@value_split+"]+)["+@value_split+"](?:\"([^\"]+)\"|'([^']+)'|([^"+@field_split+"]+))")
|
||||
scan_re = Regexp.new("((?:\\\\ |[^"+@field_split+@value_split+"])+)["+@value_split+"](?:\"([^\"]+)\"|'([^']+)'|((?:\\\\ |[^"+@field_split+"])+))")
|
||||
text.scan(scan_re) do |key, v1, v2, v3|
|
||||
value = v1 || v2 || v3
|
||||
if !@trim.nil?
|
||||
|
|
|
@ -24,6 +24,19 @@ describe LogStash::Filters::KV do
|
|||
|
||||
end
|
||||
|
||||
describe "LOGSTASH-624: allow escaped space in key or value " do
|
||||
config <<-CONFIG
|
||||
filter {
|
||||
kv { value_split => ':' }
|
||||
}
|
||||
CONFIG
|
||||
|
||||
sample 'IKE:=Quick\ Mode\ completion IKE\ IDs:=subnet:\ x.x.x.x\ (mask=\ 255.255.255.254)\ and\ host:\ y.y.y.y' do
|
||||
insist { subject["IKE"] } == '=Quick\ Mode\ completion'
|
||||
insist { subject['IKE\ IDs'] } == '=subnet:\ x.x.x.x\ (mask=\ 255.255.255.254)\ and\ host:\ y.y.y.y'
|
||||
end
|
||||
end
|
||||
|
||||
describe "test value_split" do
|
||||
config <<-CONFIG
|
||||
filter {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue