Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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