aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2014-06-06 13:38:31 +0100
committerLouise Crow <louise.crow@gmail.com>2014-06-06 13:38:31 +0100
commite011794db357859c387399fd4e6e695f2079380e (patch)
treeff91155369b9e1a207162e4646e3e6fec59cecc9
parentf1706813a99f03e1d7b1fda2d6f02fdc657ea3c3 (diff)
parent895fffedf54ae9ea4168cf03ca5aa55f93a93b49 (diff)
Merge remote-tracking branch 'origin/hotfix/0.18.0.3' into wdtk
-rw-r--r--lib/attachment_to_html/adapters/rtf.rb2
-rw-r--r--spec/lib/attachment_to_html/adapters/rtf_spec.rb11
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/attachment_to_html/adapters/rtf.rb b/lib/attachment_to_html/adapters/rtf.rb
index 859c0e541..95f499689 100644
--- a/lib/attachment_to_html/adapters/rtf.rb
+++ b/lib/attachment_to_html/adapters/rtf.rb
@@ -73,6 +73,8 @@ module AttachmentToHTML
# Works around http://savannah.gnu.org/bugs/?42015 in unrtf ~> 0.21
def sanitize_converted(html)
+ html.nil? ? html = '' : html
+
invalid = %Q(<!DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN>)
valid = %Q(<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN>")
if html.include?(invalid)
diff --git a/spec/lib/attachment_to_html/adapters/rtf_spec.rb b/spec/lib/attachment_to_html/adapters/rtf_spec.rb
index a3bf0e27e..2c53b5272 100644
--- a/spec/lib/attachment_to_html/adapters/rtf_spec.rb
+++ b/spec/lib/attachment_to_html/adapters/rtf_spec.rb
@@ -60,6 +60,17 @@ describe AttachmentToHTML::Adapters::RTF do
adapter.body.should_not include('//W3C//DTD HTML 4.01 Transitional//EN')
end
+ it 'converts empty files' do
+ attachment = FactoryGirl.build(:rtf_attachment, :body => load_file_fixture('empty.rtf'))
+ adapter = AttachmentToHTML::Adapters::RTF.new(attachment)
+ adapter.body.should == ''
+ end
+
+ it 'doesnt fail if the external command returns nil' do
+ AlaveteliExternalCommand.stub(:run).and_return(nil)
+ adapter.body.should == ''
+ end
+
end