Stream transformer that filters out XML DTD definitions.
XMLDTDFilter
takes anything between <? and > to be a
DTD. It does no escaping of quoted text.
# File lib/splunk-sdk-ruby/resultsreader.rb, line 678 def initialize(stream) @stream = stream @peeked_char = nil end
# File lib/splunk-sdk-ruby/resultsreader.rb, line 683 def close() @stream.close() end
# File lib/splunk-sdk-ruby/resultsreader.rb, line 687 def read(n=nil) response = "" while n.nil? or n > 0 # First use any element we already peeked at. if !@peeked_char.nil? response << @peeked_char @peeked_char = nil if !n.nil? n -= 1 end next end c = @stream.read(1) if c.nil? # We've reached the end of the stream break elsif c == "<" # We might have a DTD definition d = @stream.read(1) || "" if d == "?" # It's a DTD. Skip until we've consumed a >. while true q = @stream.read(1) if q == ">" break end end else # It's not a DTD. Push that ? into lookahead. @peeked_char = d response << c if !n.nil? n = n-1 end end else # No special behavior response << c if !n.nil? n -= 1 end end end return response end