Module: Zendesk::CsvScrubber

Defined in:
lib/csv_scrubber.rb

Class Method Summary collapse

Class Method Details

.macro_string?(value) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/csv_scrubber.rb', line 10

def self.macro_string?(value)
  value.is_a?(String) && value.size > 1 && value.start_with?("=", "+", "-", "@")
end

.scrub_output(value) ⇒ Object



3
4
5
6
7
8
# File 'lib/csv_scrubber.rb', line 3

def self.scrub_output(value)
  # escape macro operators at the beginning of strings to
  # prevent malicious macro injection, e.g. (=, +, -, @)
  value = "'#{value}" if macro_string?(value)
  value
end