lib/carwash/scrubber.rb in carwash-1.0.6 vs lib/carwash/scrubber.rb in carwash-1.0.7
- old
+ new
@@ -86,11 +86,12 @@
# Go through a line of text and obscure any potentially sensitive values
# detected. Makes replacements in place.
def obscure_sensitive_values!(line, obscure_with: self.obscure_with)
@sensitive_vals.each do |val|
- line.gsub!(val, obscure_with)
+ val=Regexp::escape(val)
+ line.gsub!(/#{val}/i, obscure_with)
end
end
# Scans the line to try and discover potentially sensitive values, then
# obscures all sensitive values known. Returns the line with replacements
@@ -105,10 +106,10 @@
def scrub!(line, obscure_with: self.obscure_with)
discover_sensitive_values(line)
obscure_sensitive_values!(line, obscure_with: obscure_with)
end
- # Learns from and scrubs each line of an input stream, writing the result to
+ # Learns from and scrubs each line of an input stream, writing the result to
# the given output stream.
def scrub_stream(input, output)
input.each_line do |line|
output.puts(scrub(line))
end