mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
String Interpolation skip the last character
This PR fix a problem when doing the interpolation with a string that did not end with a fieldref but with a character. The interpolation was ignoring the last character. Example: ``` "%{type}|" => "syslog" ``` Fixes #3931 Fixes #3937
This commit is contained in:
parent
7f9e81727d
commit
935ac9285b
2 changed files with 5 additions and 1 deletions
|
@ -46,7 +46,7 @@ module LogStash
|
|||
position = match.offset(0).last
|
||||
end
|
||||
|
||||
if position < template.size - 1
|
||||
if position < template.size
|
||||
nodes << StaticNode.new(template[position..-1])
|
||||
end
|
||||
|
||||
|
|
|
@ -100,6 +100,10 @@ describe LogStash::Event do
|
|||
expect(subject.sprintf("%{[j][k3]}")).to eq("{\"4\":\"m\"}")
|
||||
end
|
||||
|
||||
it "should not strip last character" do
|
||||
expect(subject.sprintf("%{type}%{message}|")).to eq("sprintfhello world|")
|
||||
end
|
||||
|
||||
context "#encoding" do
|
||||
it "should return known patterns as UTF-8" do
|
||||
expect(subject.sprintf("%{message}").encoding).to eq(Encoding::UTF_8)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue