From 2253032ebc46837450ff8fc1c43f087627ec26b7 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Sat, 29 Feb 2020 04:21:53 +0000 Subject: [PATCH] Newline between list items break a list (#32971). Patch by Yuichi HARADA. git-svn-id: http://svn.redmine.org/redmine/trunk@19536 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- .../wiki_formatting/textile/redcloth3.rb | 11 ++++++----- .../wiki_formatting/textile_formatter_test.rb | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/lib/redmine/wiki_formatting/textile/redcloth3.rb b/lib/redmine/wiki_formatting/textile/redcloth3.rb index 80e0a3626..c9bdd0aeb 100644 --- a/lib/redmine/wiki_formatting/textile/redcloth3.rb +++ b/lib/redmine/wiki_formatting/textile/redcloth3.rb @@ -1020,11 +1020,12 @@ class RedCloth3 < String end def flush_left( text ) - indt = 0 - if text =~ /^ / - unless text.empty? - indt += 1 while text !~ /^ {#{indt}}[^ ]/ - end + if /(?![\r\n\t ])[[:cntrl:]]/.match?(text) + text.gsub!(/(?![\r\n\t ])[[:cntrl:]]/, '') + end + if /^ +\S/.match?(text) + indt = 0 + indt += 1 while !/^ {#{indt}}\S/.match?(text) if indt.nonzero? text.gsub!( /^ {#{indt}}/, '' ) end diff --git a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb index 19128524e..2358ded58 100644 --- a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb +++ b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb @@ -171,6 +171,24 @@ class Redmine::WikiFormatting::TextileFormatterTest < ActionView::TestCase EXPECTED assert_equal expected.gsub(%r{\s+}, ''), to_html(raw).gsub(%r{\s+}, '') + + raw = <<~RAW + * Item-1 + + * Item-1a + * Item-1b + RAW + expected = <<~EXPECTED + + EXPECTED + assert_equal expected.gsub(%r{\s+}, ''), to_html(raw).gsub(%r{\s+}, '') end def test_escaping