Hi,
I’m trying to work through some issues using 1.9.3 for my project
RubyDNS,
and I noticed the following code in resolv.rb’s MessageEncoder:
class MessageEncoder # :nodoc:
def initialize
@data = ''
@names = {}
yield self
end
def to_s
return @data
end
def put_bytes(d)
@data << d
end
def put_pack(template, *d)
@data << d.pack(template)
end
def put_length16
length_index = *@data.length*
@data << "\0\0"
data_start = *@data.length*
yield
data_end = *@data.length*
-
@data[length_index, 2] = [data_end - data_start].pack("n")* end
I’m just wondering, shouldn’t this be using byteslice, bytesize and
friends? Isn’t this code completely broken by default since we use UTF-8
encoding? Am I missing something?
Kind regards,
Samuel