Defect #31232

Text may unexpectedly be enclosed in pre tags when an issue is created via HTML email

Added by Go MAEDA 6 months ago. Updated 4 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Email receiving
Target version:4.1.0
Resolution:Fixed Affected version:

Description

You sometimes see unexpected pre blocks if you create an issue by sending an HTML email. Please see the example below.

[Input]

<div>foo</div>
<p>
  bar
</p>

[Expected]

[Actual]

This can be fixed by stripping preceding whitespaces from each line in the HTML.

diff --git a/lib/redmine/wiki_formatting/html_parser.rb b/lib/redmine/wiki_formatting/html_parser.rb
index 62445ff3b..b3b45f590 100644
--- a/lib/redmine/wiki_formatting/html_parser.rb
+++ b/lib/redmine/wiki_formatting/html_parser.rb
@@ -30,7 +30,7 @@ module Redmine
       }

       def self.to_text(html)
-        html = html.gsub(/[\n\r]/, '').squeeze(' ')
+        html = html.gsub(/^\s+/, '').tr("\n\r", '').squeeze(' ')

         doc = Loofah.document(html)
         doc.scrub!(WikiTags.new(tags))

expected-result@2x.png (4.59 KB) Go MAEDA, 2019-04-20 10:48

actual-result@2x.png (4.9 KB) Go MAEDA, 2019-04-20 10:49

fix-31232.patch Magnifier (1.15 KB) Go MAEDA, 2019-04-20 11:36

fix-31232-v2.patch Magnifier (1.86 KB) Go MAEDA, 2019-04-21 04:16

fix-31232-v3.patch Magnifier - Update for r18070 (1.85 KB) Go MAEDA, 2019-04-21 15:51


Related issues

Blocks Redmine - Feature #31231: Better handling of HTML tables when creating an issue fro... Closed

Associated revisions

Revision 18268
Added by Jean-Philippe Lang 4 months ago

Text may unexpectedly be enclosed in pre tags when an issue is created via HTML email (#31232).

Patch by Go MAEDA.

History

#1 Updated by Go MAEDA 6 months ago

Here is a patch with test code.

#2 Updated by Go MAEDA 6 months ago

  • Blocks Feature #31231: Better handling of HTML tables when creating an issue from an email added

#3 Updated by Go MAEDA 6 months ago

  • File fix-31232-v2.patchMagnifier added
  • Subject changed from Some text is unexpectedly enclosed in pre tags when creating an issue via HTML email to Text may be unexpectedly enclosed in pre tags when an issue is created via HTML email

Fixed some issues in the patch.

#4 Updated by Go MAEDA 6 months ago

#5 Updated by Go MAEDA 6 months ago

  • Subject changed from Text may be unexpectedly enclosed in pre tags when an issue is created via HTML email to Text may unexpectedly be enclosed in pre tags when an issue is created via HTML email
  • Target version changed from Candidate for next major release to 4.1.0

#6 Updated by Jean-Philippe Lang 4 months ago

  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang
  • Resolution set to Fixed

Committed, thanks.

Also available in: Atom PDF