From de6b0f33cde92b6028c1ef973e5fc24478890fc9 Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sat, 27 Oct 2018 13:56:25 -0400 Subject: [PATCH] extract msword html data into an asset file --- Manifest.txt | 1 + test/assets/msword.html | 63 ++++++++++++++++++++++++++++++ test/integration/test_ad_hoc.rb | 69 ++------------------------------- 3 files changed, 67 insertions(+), 66 deletions(-) create mode 100644 test/assets/msword.html diff --git a/Manifest.txt b/Manifest.txt index c579e9e2..37b67859 100644 --- a/Manifest.txt +++ b/Manifest.txt @@ -24,6 +24,7 @@ lib/loofah/scrubber.rb lib/loofah/scrubbers.rb lib/loofah/xml/document.rb lib/loofah/xml/document_fragment.rb +test/assets/msword.html test/assets/testdata_sanitizer_tests1.dat test/helper.rb test/html5/test_sanitizer.rb diff --git a/test/assets/msword.html b/test/assets/msword.html new file mode 100644 index 00000000..f1dc2e60 --- /dev/null +++ b/test/assets/msword.html @@ -0,0 +1,63 @@ + + +

Foo BOLD

diff --git a/test/integration/test_ad_hoc.rb b/test/integration/test_ad_hoc.rb index 3782fa00..29af40be 100644 --- a/test/integration/test_ad_hoc.rb +++ b/test/integration/test_ad_hoc.rb @@ -17,6 +17,8 @@ class IntegrationTestAdHoc < Loofah::TestCase end context "tests" do + MSWORD_HTML = File.read(File.join(File.dirname(__FILE__), "..", "assets", "msword.html")).freeze + def test_removal_of_illegal_tag html = <<-HTML following this there should be no jim tag @@ -76,72 +78,6 @@ def test_whitewash_on_fragment assert_equal "

safe

description", whitewashed.gsub("\n","") end - MSWORD_HTML = <<-EOHTML - - -

Foo BOLD

- EOHTML - def test_fragment_whitewash_on_microsofty_markup whitewashed = Loofah.fragment(MSWORD_HTML).scrub!(:whitewash) assert_equal "

Foo BOLD

", whitewashed.to_s.strip @@ -254,5 +190,6 @@ def test_dont_remove_whitespace_between_tags end end + end end