Skip to content

Commit

Permalink
Ensure that empty content doesn't raise an exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Rust committed Apr 9, 2012
1 parent 977d78f commit a034fde
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/readability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Document

def initialize(input, options = {})
@options = DEFAULT_OPTIONS.merge(options)
@input = input
@input = fix_blank_input(input)

if RUBY_VERSION =~ /^1\.9\./ && !@options[:encoding]
@input = GuessHtmlEncoding.encode(@input, @options[:html_headers]) unless @options[:do_not_guess_encoding]
Expand Down Expand Up @@ -409,5 +409,9 @@ def clean_conditionally(node, candidates, selector)
end
end

protected
def fix_blank_input(input)
input.empty? ? '<body />' : ''
end
end
end

0 comments on commit a034fde

Please sign in to comment.