class PNGlitch::DataSizeError

Public Class Methods

new(filename, over, expected) click to toggle source
Calls superclass method
# File lib/pnglitch/errors.rb, line 4
    def initialize filename, over, expected
      over_size = digit_format over
      expected_size = digit_format expected
      message = <<-EOL.gsub(/^\s*/, '')
        The size of your data goes over #{over_size}.
        It should be #{expected_size} actually when it's a normal 
        formatted PNG file.
        PNGlitch raised this error to avoid the attack known as
        "zip bomb". If you are sure that the PNG image is safe, 
        please set manually your own upper size limit as the variable
        of PNGlitch#open.
      EOL
      message = ["\e[31m", message, "\e[0m"].join if STDOUT.tty?  # color red
      message = [
        'Size of the decompressed data is too large - ', 
        filename, "\n\n", message, "\n"
      ].join
      super message
    end