Method: Rex::Text.ungzip

Defined in:
lib/rex/text.rb

.ungzip(str) ⇒ String

Uncompresses a string using gzip

Parameters:

  • str (String)

    Compressed string to inflate

Returns:

  • (String)

    The uncompressed version of str

Raises:



1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
# File 'lib/rex/text.rb', line 1491

def self.ungzip(str)
  raise RuntimeError, "Gzip support is not present." if (!zlib_present?)

  s = ""
  s.force_encoding('ASCII-8BIT') if s.respond_to?(:encoding)
  gz = Zlib::GzipReader.new(StringIO.new(str, 'rb'))
  s << gz.read
  gz.close
  return s
end