Skip to content

Commit

Permalink
filter/xml fix for LOGSTASH-2246: extract non-ascii content with xpath
Browse files Browse the repository at this point in the history
  • Loading branch information
wiibaa authored and jordansissel committed Sep 29, 2014
1 parent 96c5e32 commit 7395512
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/logstash/filters/xml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def filter(event)
unless value.nil?
matched = true
event[xpath_dest] ||= []
event[xpath_dest] << value.to_s
event[xpath_dest] << value.to_str
end
end # XPath.each
end # @xpath.each
Expand Down
19 changes: 19 additions & 0 deletions spec/filters/xml.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# encoding: utf-8
require "test_utils"
require "logstash/filters/xml"

Expand Down Expand Up @@ -154,4 +155,22 @@
end
end

describe "parse correctly non ascii content with xpath" do
config <<-CONFIG
filter {
xml {
source => "xmldata"
target => "data"
xpath => [ "/foo/key/text()", "xpath_field" ]
}
}
CONFIG

# Single value
sample("xmldata" => '<foo><key>Français</key></foo>') do
insist { subject["tags"] }.nil?
insist { subject["xpath_field"]} == ["Français"]
end
end

end

0 comments on commit 7395512

Please sign in to comment.