From 1c1398d60ce463621d5c7040cf035ab843b49014 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 22 Jun 2016 16:39:20 +0200 Subject: [PATCH] Improved html2text to remove html comments. --- lib/core_ext/string.rb | 3 +++ test/unit/aaa_string_test.rb | 13 +++++++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/core_ext/string.rb b/lib/core_ext/string.rb index 98b3071d9..a81cf8073 100644 --- a/lib/core_ext/string.rb +++ b/lib/core_ext/string.rb @@ -88,6 +88,9 @@ class String string = string.chars.select(&:valid_encoding?).join end + # remove html comments + string.gsub!(//m, '') + # find and replace it with [x] link_list = '' counter = 0 diff --git a/test/unit/aaa_string_test.rb b/test/unit/aaa_string_test.rb index ebf6ccf7b..4b2851c37 100644 --- a/test/unit/aaa_string_test.rb +++ b/test/unit/aaa_string_test.rb @@ -141,6 +141,19 @@ class AaaStringTest < ActiveSupport::TestCase result = "test\n\n___" assert_equal(result, html.html2text) + html = "Ihr RZ-Team
+
+" + result = 'Ihr RZ-Team' + assert_equal(result, html.html2text) + html = ' line 1
you
-----&'