Skip to content
Merged
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 3.0.10
- Extend `spreadsheet_safe` prefix guard to '-', '+', and '@' [#27](https://github.com/logstash-plugins/logstash-output-csv/pull/27)

## 3.0.9
- Fix: updates syntax to JRuby 9.4 [#25](https://github.com/logstash-plugins/logstash-output-csv/pull/25)

Expand Down
2 changes: 1 addition & 1 deletion lib/logstash/outputs/csv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ def get_value(name, event)

private
def escape_csv(val)
(spreadsheet_safe && val.is_a?(String) && val.start_with?("=")) ? "'#{val}" : val
(spreadsheet_safe && val.is_a?(String) && val.start_with?(/[=+\-@]/)) ? "'#{val}" : val
end
end # class LogStash::Outputs::CSV
2 changes: 1 addition & 1 deletion logstash-output-csv.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|

s.name = 'logstash-output-csv'
s.version = '3.0.9'
s.version = '3.0.10'
s.licenses = ['Apache License (2.0)']
s.summary = "Writes events to disk in a delimited format"
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
Expand Down
10 changes: 8 additions & 2 deletions spec/outputs/csv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,24 @@
let(:event_data) do
{
"f1" => "1+1",
"f2" => "=1+1"
"f2" => "=1+1",
"f3" => "+1+1",
"f4" => "-1+1",
"f5" => "@1+1"
}
end
let(:events) do
[ LogStash::Event.new(event_data) ]
end

let(:options) { { "path" => tmpfile, "fields" => ["f1", "f2"] } }
let(:options) { { "path" => tmpfile, "fields" => ["f1", "f2", "f3", "f4", "f5"] } }
it "escapes them correctly" do
expect(csv_output.size).to eq(1)
expect(csv_output[0][0]).to eq("1+1")
expect(csv_output[0][1]).to eq("'=1+1")
expect(csv_output[0][2]).to eq("'+1+1")
expect(csv_output[0][3]).to eq("'-1+1")
expect(csv_output[0][4]).to eq("'@1+1")
end

context "when escaping is turned off" do
Expand Down