diff --git a/lib/whois/parsers/base.rb b/lib/whois/parsers/base.rb index 9acbae4f..9997d6c6 100644 --- a/lib/whois/parsers/base.rb +++ b/lib/whois/parsers/base.rb @@ -363,7 +363,7 @@ def response_unavailable? protected def content_for_scanner - @content_for_scanner ||= content.to_s.gsub(/\r\n/, "\n") + @content_for_scanner ||= "#{content.to_s.gsub(/\r\n/, "\n").gsub(/\n$/, '')}\n" end def cached_properties_fetch(key) diff --git a/spec/whois/parsers/base_spec.rb b/spec/whois/parsers/base_spec.rb index 97bbfb86..1c23ba1d 100644 --- a/spec/whois/parsers/base_spec.rb +++ b/spec/whois/parsers/base_spec.rb @@ -71,16 +71,21 @@ end describe "#content_for_scanner" do + it "returns the part body with line feed normalized" do + instance = described_class.new(Whois::Record::Part.new(:body => "This is\r\nthe response.\r\n", :host => "whois.example.test")) + expect(instance.send(:content_for_scanner)).to eq("This is\nthe response.\n") + end + it "returns the part body with line feed normalized" do instance = described_class.new(Whois::Record::Part.new(:body => "This is\r\nthe response.", :host => "whois.example.test")) - expect(instance.send(:content_for_scanner)).to eq("This is\nthe response.") + expect(instance.send(:content_for_scanner)).to eq("This is\nthe response.\n") end it "caches the result" do instance = described_class.new(Whois::Record::Part.new(:body => "This is\r\nthe response.", :host => "whois.example.test")) expect(instance.instance_eval { @content_for_scanner }).to be_nil instance.send(:content_for_scanner) - expect(instance.instance_eval { @content_for_scanner }).to eq("This is\nthe response.") + expect(instance.instance_eval { @content_for_scanner }).to eq("This is\nthe response.\n") end end