diff options
author | Gareth Rees <gareth@mysociety.org> | 2014-04-01 11:59:26 +0100 |
---|---|---|
committer | Gareth Rees <gareth@mysociety.org> | 2014-04-01 12:17:00 +0100 |
commit | 08572fe8d0ad97c01ecc5c0f0ee39e610de383a3 (patch) | |
tree | 7703d94e9513844425352f39ebac50c42c66a8c3 /spec/lib/attachment_to_html | |
parent | 82c69083609ad14b127c0037ecc8c4df959654ac (diff) |
Work around a bug in unrtf
Diffstat (limited to 'spec/lib/attachment_to_html')
-rw-r--r-- | spec/lib/attachment_to_html/adapters/rtf_spec.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/lib/attachment_to_html/adapters/rtf_spec.rb b/spec/lib/attachment_to_html/adapters/rtf_spec.rb index f84073c51..75fd467f6 100644 --- a/spec/lib/attachment_to_html/adapters/rtf_spec.rb +++ b/spec/lib/attachment_to_html/adapters/rtf_spec.rb @@ -69,6 +69,31 @@ describe AttachmentToHTML::Adapters::RTF do rtf_adapter.to_html end + it 'does not result in incorrect conversion when unrtf returns an invalid doctype' do + # Doctype public identifier is unquoted + # Valid doctype would be: + # <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> + # See bug report http://savannah.gnu.org/bugs/?42015 + invalid = <<-DOC + <!DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN> + <html> + <head> + <meta http-equiv="content-type" content="text/html; charset=utf-8"> + <!-- Translation from RTF performed by UnRTF, version 0.21.5 --> + <!--font table contains 0 fonts total--> + <!--invalid font number 0--> + </head> + <body><font size="3"><font color="#000000">thisisthebody</font></font></body> + </html> + DOC + AlaveteliExternalCommand.stub(:run).and_return(invalid) + + parsed = Nokogiri::HTML.parse(rtf_adapter.to_html) do |config| + config.strict + end + parsed.css('body').inner_text.should_not include('//W3C//DTD HTML 4.01 Transitional//EN') + end + end describe :success? do |