From 8971dafa8d4698b3c45efff63a4ed129e8ad284c Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 5 Feb 2005 18:31:20 +0000 Subject: [PATCH] * lib/resolv.rb (Resolv::DNS::Resource::TXT): multiple strings was not handled. (Resolv::DNS::Resource::TXT#strings): new method to return all strings. (Resolv::DNS::Message::MessageEncoder#put_string_list): new method. (Resolv::DNS::Message::MessageDecoder#get_string_list): ditto. based on [ruby-talk:129732] by Sam Roberts. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 10 ++++++++++ lib/resolv.rb | 30 ++++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index de434679bb..c9cb3b686d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Sun Feb 6 03:24:20 2005 Tanaka Akira + + * lib/resolv.rb (Resolv::DNS::Resource::TXT): multiple strings was not + handled. + (Resolv::DNS::Resource::TXT#strings): new method to return all + strings. + (Resolv::DNS::Message::MessageEncoder#put_string_list): new method. + (Resolv::DNS::Message::MessageDecoder#get_string_list): ditto. + based on [ruby-talk:129732] by Sam Roberts. + Sat Feb 5 02:24:06 2005 Minero Aoki * test/ripper/test_scanner_events.rb: fix test. diff --git a/lib/resolv.rb b/lib/resolv.rb index 28847f4bb2..3861d9190d 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -1154,6 +1154,12 @@ class Resolv @data << d end + def put_string_list(ds) + ds.each {|d| + self.put_string(d) + } + end + def put_name(d) put_labels(d.to_a) end @@ -1266,6 +1272,14 @@ class Resolv return d end + def get_string_list + strings = [] + while @index < @limit + strings << self.get_string + end + strings + end + def get_name return Name.new(self.get_labels) end @@ -1508,18 +1522,22 @@ class Resolv class TXT < Resource TypeValue = 16 - def initialize(data) - @data = data + def initialize(first_string, *rest_strings) + @strings = [first_string, *rest_strings] + end + attr_reader :strings + + def data + @strings[0] end - attr_reader :data def encode_rdata(msg) - msg.put_string(@data) + msg.put_string_list(@strings) end def self.decode_rdata(msg) - data = msg.get_string - return self.new(data) + strings = msg.get_string_list + return self.new(*strings) end end