Fixes #3596, Force Rex::Text.gzip to use ASCII-8BIT strings, Reverts r10653
git-svn-id: file:///home/svn/framework3/trunk@11639 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
05fd7b4e57
commit
1e6365ed58
|
@ -166,9 +166,8 @@ class Packet
|
|||
# Converts the packet to a string.
|
||||
#
|
||||
def to_s
|
||||
# Duplicate and make sure this is 8BIT safe for Ruby 1.9
|
||||
content = self.body.unpack("C*").pack("C*")
|
||||
|
||||
content = self.body.dup
|
||||
|
||||
# Update the content length field in the header with the body length.
|
||||
if (content)
|
||||
if !self.compress.nil?
|
||||
|
@ -267,7 +266,7 @@ protected
|
|||
def parse_header
|
||||
|
||||
head,data = self.bufq.split(/\r?\n\r?\n/, 2)
|
||||
|
||||
|
||||
return if not data
|
||||
|
||||
self.headers.from_s(head)
|
||||
|
@ -339,7 +338,7 @@ protected
|
|||
|
||||
# If we didn't get a newline, then this might not be the full
|
||||
# length, go back and get more.
|
||||
# e.g.
|
||||
# e.g.
|
||||
# first packet: "200"
|
||||
# second packet: "0\r\n\r\n<html>..."
|
||||
if not bufq.index("\n")
|
||||
|
@ -350,7 +349,7 @@ protected
|
|||
clen = self.bufq.slice!(/^[a-fA-F0-9]+\r?\n/)
|
||||
|
||||
clen.rstrip! if (clen)
|
||||
|
||||
|
||||
# if we happen to fall upon the end of the buffer for the next chunk len and have no data left, go get some more...
|
||||
if clen.nil? and self.bufq.length == 0
|
||||
return
|
||||
|
|
|
@ -237,7 +237,7 @@ module Text
|
|||
#
|
||||
def self.to_hex_ascii(str, prefix = "\\x", count = 1, suffix=nil)
|
||||
raise ::RuntimeError, "unable to chunk into #{count} byte chunks" if ((str.length % count) > 0)
|
||||
return str.unpack('H*')[0].gsub(Regexp.new(".{#{count * 2}}", nil, 'n')) { |s|
|
||||
return str.unpack('H*')[0].gsub(Regexp.new(".{#{count * 2}}", nil, 'n')) { |s|
|
||||
(0x20..0x7e) === s.to_i(16) ? s.to_i(16).chr : prefix + s + suffix.to_s
|
||||
}
|
||||
end
|
||||
|
@ -795,7 +795,7 @@ module Text
|
|||
sets.size.times { counter << 0}
|
||||
0.upto(len-1) do |i|
|
||||
setnum = i % sets.size
|
||||
|
||||
|
||||
puts counter.inspect
|
||||
end
|
||||
|
||||
|
@ -891,7 +891,8 @@ module Text
|
|||
raise RuntimeError, "Invalid gzip compression level" if (level < 1 or level > 9)
|
||||
|
||||
s = ""
|
||||
gz = Zlib::GzipWriter.new(StringIO.new(s), level)
|
||||
s.force_encoding('ASCII-8BIT')
|
||||
gz = Zlib::GzipWriter.new(StringIO.new(s, 'wb'), level)
|
||||
gz << str
|
||||
gz.close
|
||||
return s
|
||||
|
@ -904,7 +905,8 @@ module Text
|
|||
raise RuntimeError, "Gzip support is not present." if (!zlib_present?)
|
||||
|
||||
s = ""
|
||||
gz = Zlib::GzipReader.new(StringIO.new(str))
|
||||
s.force_encoding('ASCII-8BIT')
|
||||
gz = Zlib::GzipReader.new(StringIO.new(str, 'rb'))
|
||||
s << gz.read
|
||||
gz.close
|
||||
return s
|
||||
|
|
Loading…
Reference in New Issue