Sha256: 47807281807de0dbd30b8dc1597149bb5667fa0e92cdb4e00d5fee6410b2a345

Contents?: true

Size: 756 Bytes

Versions: 5

Compression:

Stored size: 756 Bytes

Contents

module Imap::Backup
  class Sanitizer
    attr_reader :output

    def initialize(output)
      @output = output
      @current = ""
    end

    def write(*args)
      output.write(*args)
    end

    def print(*args)
      @current << args.join
      loop do
        line, newline, rest = @current.partition("\n")
        break if newline != "\n"
        clean = sanitize(line)
        output.puts clean
        @current = rest
      end
    end

    def flush
      return if @current == ""

      clean = sanitize(@current)
      output.puts clean
    end

    private

    def sanitize(t)
      # Hide password in Net::IMAP debug output
      t.gsub(
        /\A(C: RUBY\d+ LOGIN \S+) \S+/,
        "\\1 [PASSWORD REDACTED]"
      )
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
imap-backup-4.2.2 lib/imap/backup/sanitizer.rb
imap-backup-4.2.1 lib/imap/backup/sanitizer.rb
imap-backup-4.2.0 lib/imap/backup/sanitizer.rb
imap-backup-4.1.2 lib/imap/backup/sanitizer.rb
imap-backup-4.1.1 lib/imap/backup/sanitizer.rb